2014-10-16 47 views
0

我想自定義類別博客佈局只有一個類別列示如下:的Joomla 3.3.6分類博客 - 文章之前小類

  • 這個特殊類別(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我必須失去了一些東西:)任何人都可以請幫助? 非常感謝。

回答

0

使用此調試您的代碼link在我看來,它似乎抱怨blog_children第63行的$ item。使用前面提供的鏈接檢查ContentViewCategory類的所有有效屬性