简体   繁体   中英

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

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 wanting 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM