开发者

Get all articles of a category in a section view in Joomla

开发者 https://www.devze.com 2023-02-13 10:11 出处:网络
For some reason the Joomla docs are not very friendly to people that don\'t already know how things are done beforehand.

For some reason the Joomla docs are not very friendly to people that don't already know how things are done beforehand.

What I want is, I have two categories in each section, and I want to list all articles in the first one. I tried anything like this:

<p><?php echo count($this->categories); ?></p>
<?php if (count($this->categories) > 0) :
    $category = $this->categories[0];

    $this->items =& $category->getItems();
    echo $this->loadTemplate('items');
endif;
?>

I took that out of the other, pre-defined templates, but this only seems to work within the category-context (for the lack of a better word here). Joomla Docs and Google turned up nothing, am I the only one w开发者_StackOverflowanting that?


That bit of code doesn't work because the Section model and view do not have a function for getting that information.

You would be better off overriding the Category listing than hacking up the Section model and view. Unless there is a compelling reason to do otherwise, change your menu type from Articles >> Section to Articles >> Category >> Blog Layout. The blog layout will display link, title, and into content just by using the built in parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号