Joomla 3.3.6类别博客 - 文章前的子类别

时间:2014-10-16 16:23:36

标签: joomla joomla3.0

我正在尝试仅针对一个类别自定义类别博客布局,如下所示:

  • 此特殊类别(ID 24)博客布局应显示其列表 文章之前的子类别
  • 其他类别将坚持默认布局:首先是文章,然后是 子类别

我试过覆盖blog.php:

<div class="blog<?php echo $this->pageclass_sfx; ?>" itemscope itemtype="http://schema.org/Blog">

<!-- SPECIAL CATEGORY - SUBCATEGORIES FIRST -->
<?php if ($this->category->id == 24 && !empty($this->children[$this->category->id]) && $this->maxLevel != 0) : ?>
    <div class="cat-children">
        <?php if ($this->params->get('show_category_heading_title_text', 1) == 1) : ?>
            <h3> <?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?> </h3>
        <?php endif; ?>
        <?php echo $this->loadTemplate('children'); ?> </div>
<?php endif; ?>

<?php
$introcount = (count($this->intro_items));
$counter = 0;
?>

<?php if (!empty($this->intro_items)) : ?>
    <?php foreach ($this->intro_items as $key => &$item) : ?>
        <?php $rowcount = ((int) $key % (int) $this->columns) + 1; ?>
        <?php if ($rowcount == 1) : ?>
            <?php $row = $counter / $this->columns; ?>
            <div class="items-row cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row-fluid clearfix">
        <?php endif; ?>
        <div class="span<?php echo round((12 / $this->columns)); ?>">
            <div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"
                itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
                <?php
                $this->item = & $item;
                echo $this->loadTemplate('item');
                ?>
            </div>
            <!-- end item -->
            <?php $counter++; ?>
        </div><!-- end span -->
        <?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>
            </div><!-- end row -->
        <?php endif; ?>
    <?php endforeach; ?>
<?php endif; ?>

<?php if (!empty($this->link_items)) : ?>
    <div class="items-more">
        <?php echo $this->loadTemplate('links'); ?>
    </div>
<?php endif; ?>

<!-- OTHER CATEGORIES - SUBCATEGORIES LAST -->
<?php if (!empty($this->children[$this->category->id]) && $this->maxLevel != 0 && $this->category->id != 24) : ?>
    <div class="cat-children">
        <?php if ($this->params->get('show_category_heading_title_text', 1) == 1) : ?>
            <h3> <?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?> </h3>
        <?php endif; ?>
        <?php echo $this->loadTemplate('children'); ?> </div>
<?php endif; ?>

<?php if (($this->params->def('show_pagination', 1) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?>
    <div class="pagination">
        <?php if ($this->params->def('show_pagination_results', 1)) : ?>
            <p class="counter pull-right"> <?php echo $this->pagination->getPagesCounter(); ?> </p>
        <?php endif; ?>
        <?php echo $this->pagination->getPagesLinks(); ?> </div>
<?php endif; ?>

它对其他类别显示正常,但在尝试查看特殊类别时,我得到了这个:

    {category title}

{description}


Notice: Undefined property: ContentViewCategory::$item in {joomla}\templates\wse\html\com_content\category\blog_children.php on line 63

Notice: Undefined property: ContentViewCategory::$item in {joomla}\templates\wse\html\com_content\category\blog_children.php on line 63

Notice: Trying to get property of non-object in {joomla}\templates\wse\html\com_content\category\blog_children.php on line 63

Fatal error: Call to a member function get() on a non-object in {joomla}\layouts\joomla\content\readmore.php on line 17

所以我一定要错过一些东西:)有人可以帮忙吗? 非常感谢。

1 个答案:

答案 0 :(得分:0)

使用此调试您的代码link在我看来,它抱怨blog_children第63行的$ item。使用前面提供的链接检查ContentViewCategory类的所有有效属性