【问题标题】:Joomla 3.3.6 Category Blog - Subcategories before articlesJoomla 3.3.6 类别博客 - 文章之前的子类别
【发布时间】:2014-10-16 16:23:36
【问题描述】:

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

  • 此特殊类别 (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

Sooo 我一定是遗漏了一些东西 :) 有人可以帮忙吗? 非常感谢。

【问题讨论】:

    标签: joomla joomla3.0


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-23
      • 2023-03-28
      • 2014-11-05
      • 1970-01-01
      • 2013-07-10
      • 1970-01-01
      • 2014-11-30
      • 1970-01-01
      相关资源
      最近更新 更多