Keyword

"extra fields"

More
5 years 9 months ago #171033 by David
"extra fields" was created by David
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
5 years 9 months ago #171039 by Emanuel Rodríguez
Replied by Emanuel Rodríguez on 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.

More
5 years 9 months ago #171044 by JoomlaWorks
Replied by JoomlaWorks on 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>

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum