0

これでレンガの壁に頭をぶつけて数日過ごしたので、助けが必要です. 私は基本的にここでコードを変更したい:

<div class="itemList">

        <?php if(isset($this->leading) && count($this->leading)): ?>
        <!-- Leading items -->
        <div id="itemListLeading">
            <?php foreach($this->leading as $key=>$item): ?>

            <?php
            // Define a CSS class for the last container on each row
            if( (($key+1)%($this->params->get('num_leading_columns'))==0) || count($this->leading)<$this->params->get('num_leading_columns') )
                $lastContainer= ' itemContainerLast';
            else
                $lastContainer='';
            ?>

            <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->leading)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_leading_columns'), 1).'%;"'; ?>>
                <?php
                    // Load category_item.php by default
                    $this->item=$item;
                    echo $this->loadTemplate('item');
                ?>
            </div>
            <?php if(($key+1)%($this->params->get('num_leading_columns'))==0): ?>
            <div class="clr"></div>
            <?php endif; ?>
            <?php endforeach; ?>
            <div class="clr"></div>
        </div>
        <?php endif; ?>

        <?php if(isset($this->primary) && count($this->primary)): ?>
        <!-- Primary items -->
        <div id="itemListPrimary">
            <?php foreach($this->primary as $key=>$item): ?>

            <?php
            // Define a CSS class for the last container on each row
            if( (($key+1)%($this->params->get('num_primary_columns'))==0) || count($this->primary)<$this->params->get('num_primary_columns') )
                $lastContainer= ' itemContainerLast';
            else
                $lastContainer='';
            ?>

            <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->primary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_primary_columns'), 1).'%;"'; ?>>
                <?php
                    // Load category_item.php by default
                    $this->item=$item;
                    echo $this->loadTemplate('item');
                ?>
            </div>
            <?php if(($key+1)%($this->params->get('num_primary_columns'))==0): ?>
            <div class="clr"></div>
            <?php endif; ?>
            <?php endforeach; ?>
            <div class="clr"></div>
        </div>
        <?php endif; ?>

        <?php if(isset($this->secondary) && count($this->secondary)): ?>
        <!-- Secondary items -->
        <div id="itemListSecondary">
            <?php foreach($this->secondary as $key=>$item): ?>

            <?php
            // Define a CSS class for the last container on each row
            if( (($key+1)%($this->params->get('num_secondary_columns'))==0) || count($this->secondary)<$this->params->get('num_secondary_columns') )
                $lastContainer= ' itemContainerLast';
            else
                $lastContainer='';
            ?>

            <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->secondary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_secondary_columns'), 1).'%;"'; ?>>
                <?php
                    // Load category_item.php by default
                    $this->item=$item;
                    echo $this->loadTemplate('item');
                ?>
            </div>
            <?php if(($key+1)%($this->params->get('num_secondary_columns'))==0): ?>
            <div class="clr"></div>
            <?php endif; ?>
            <?php endforeach; ?>
            <div class="clr"></div>
        </div>
        <?php endif; ?>

        <?php if(isset($this->links) && count($this->links)): ?>
        <!-- Link items -->
        <div id="itemListLinks">
            <h4><?php echo JText::_('K2_MORE'); ?></h4>
            <?php foreach($this->links as $key=>$item): ?>

            <?php
            // Define a CSS class for the last container on each row
            if( (($key+1)%($this->params->get('num_links_columns'))==0) || count($this->links)<$this->params->get('num_links_columns') )
                $lastContainer= ' itemContainerLast';
            else
                $lastContainer='';
            ?>

            <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->links)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_links_columns'), 1).'%;"'; ?>>
                <?php
                    // Load category_item_links.php by default
                    $this->item=$item;
                    echo $this->loadTemplate('item_links');
                ?>
            </div>
            <?php if(($key+1)%($this->params->get('num_links_columns'))==0): ?>
            <div class="clr"></div>
            <?php endif; ?>
            <?php endforeach; ?>
            <div class="clr"></div>
        </div>
        <?php endif; ?>

    </div>

そのため、'leading' は特定の数の記事を表示し、'primary' は次の 2 つを表示し、'secondary' は次の 4 つを表示します。

それを行う方法についての助けは素晴らしいでしょう

4

1 に答える 1