使用自定义php更改Joomla文章列表的布局

时间:2013-01-11 13:18:54

标签: php joomla

我花了几天时间用一块砖头撞到了一堵砖墙,我需要一些帮助。我基本上想在这里更改代码:

<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'显示接下来的两个,'secondary'显示接下来的四个,依此类推。

如何做到这一点的任何帮助都会很棒

1 个答案:

答案 0 :(得分:0)

该文件位于:

  

/layouts/joomla/content/category_default.php

要覆盖它,请在此处放置一份副本:

  

[your_template中] / HTML /布局/的Joomla /内容/

您可以在此处阅读有关Joomla布局的更多信息:

Sharing layouts across views or extensions with JLayout