7 years 9 months ago #171033
COMMUNITY FORUM
- Forum
- K2 Community Forum
- Comunidad hispana oficial de K2
- "extra fields"
"extra fields"
7 years 9 months ago #171039
Sí es posible. Inicialmente pensaría que lo más fácil sería por medio de CSS modificando el div correspondiente a los campos adicionales. Si tuvieras un enlace que pudieras compartir para ver específicamente en tu sitio sería mejor. Sino, puedes encontrar una posible solución siguiendo estos enlaces:
www.w3schools.com/css/css3_multiple_columns.asp
www.w3schools.com/howto/howto_css_two_columns.asp
www.w3schools.com/css/css3_multiple_columns.asp
www.w3schools.com/howto/howto_css_two_columns.asp
Admin
7 years 9 months ago #171044
You can also break the foreach loop that outputs the extra fields into as many columns as you want. In this case, you would edit the file item.php in K2's templates and change this code:
to this:
<!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?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; ?> alias<?php echo ucfirst($extraField->alias); ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>to this:
<!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
<?php
$efColumns = 3; /* Set how many columns to split extra fields into */
$efTotal = count($this->item->extra_fields); /* How many extra fields do we have */
$efPerColumn = ($efTotal > $efColumns) ? round($efTotal / $efColumns) : 1;
$efCounter = 1;
?>
<?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; ?> alias<?php echo ucfirst($extraField->alias); ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php if($efCounter >= $efPerColumn && $efCounter%$efPerColumn == 0): /* Reached column count so break the ul */ ?>
</ul>
<ul>
<?php endif; ?>
<?php $efCounter++; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>Log in or create an account to reply.