Keyword

"extra fields"

More
2 months 3 weeks ago #171033 by David
David created the topic: "extra fields"
Tengo una lista muy extensa de "Extra Fields" y necesito desplegarla en dos o mas columnas ¿es posible eso?
Attachments:

Please Log in or Create an account to join the conversation.

  • Emanuel Rodríguez
  • Emanuel Rodríguez's Avatar
  • Offline
  • Moderator
  • Robustiana.com
More
2 months 3 weeks ago #171039 by Emanuel Rodríguez
Emanuel Rodríguez replied the topic: "extra fields"
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

Robustiana.com ... Tutoriales, guías de uso y resolución de problemas en Joomla! y K2

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 months 3 weeks ago #171044 by Fotis
Fotis replied the topic: "extra fields"
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:
        <!-- 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>


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.

Moderators: william whiteEmanuel Rodríguez

Powered by Kunena Forum