2013-02-19 52 views
0

我想在單個分類中顯示文章數。分類中的文章數

$categoryName = "CategoryName"; 
$n = count($this->category->$categoryName); 
echo "This category has ".$n." articles in it!"; 

這不起作用(示例)。

回答

0

有讓你已經做到這一點的參數。分配類別列表分類博客菜單項,然後根據類別選項參數選項卡中選擇。更改沒有文章消息要顯示。

你的代碼是不工作的原因 - 是因爲一個單一的類別只是$this->category表示。

然而,對於任何一類的博客或類別列表佈局,您可以簡單地使用:

$categoryName = "CategoryName"; 
if($this->category->title==$categoryName) { 
    count($this->category->getNumItems(true)) 
} 

http://docs.joomla.org/Help25:Menus_Menu_Item_Article_Category_Blog#Category_Options

0

試試這個。

默認類別佈局包含其中的文章數量。

看看這個components\com_content\views\categories\tmpl

你也可以找到數count($item->getChildren())

但願這你..