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

4.3k views Asked by At

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?

1

There are 1 answers

4
Brent Friar On BEST ANSWER

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.