I just submitted this as a bug but I'd like to find a solution:
I created several extra fields, I filled them out, I left one field blank. When viewing an item, the css should alternate in classes 'odd' and 'even' and skip empty fields. This does not happen. As expected the fields don't show, but the odd-even alternator does not change, resulting in unwanted template output.
Example expected: odd - even - odd [EMPTY FIELD SO NO OUTPUT] - odd [ODD AGAIN] - even - odd - even
Example actual outcome: odd - even - odd [EMPTY FIELD SO NO OUTPUT] - even [SHOULD HAVE BEEN ODD!] - even - odd - even
The following code comes from the default item.php template:
As you can see, there is a mechanism to exclude empty fields and it's this:
But for some reason it does not apply to:
Does anyone know a solution for this problem? I'm not skilled enough in php to find out why exactly this doesn't work.
I created several extra fields, I filled them out, I left one field blank. When viewing an item, the css should alternate in classes 'odd' and 'even' and skip empty fields. This does not happen. As expected the fields don't show, but the odd-even alternator does not change, resulting in unwanted template output.
Example expected: odd - even - odd [EMPTY FIELD SO NO OUTPUT] - odd [ODD AGAIN] - even - odd - even
Example actual outcome: odd - even - odd [EMPTY FIELD SO NO OUTPUT] - even [SHOULD HAVE BEEN ODD!] - even - odd - even
The following code comes from the default item.php template:
<div class="itemExtraFields">
<?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>As you can see, there is a mechanism to exclude empty fields and it's this:
<?php if($extraField->value): ?>But for some reason it does not apply to:
<?php echo ($key%2) ? "odd" : "even"; ?>Does anyone know a solution for this problem? I'm not skilled enough in php to find out why exactly this doesn't work.