0

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?

hakre
  • 193,403
  • 52
  • 435
  • 836
Lanbo
  • 15,118
  • 16
  • 70
  • 147

1 Answers1

2

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.

Brent Friar
  • 10,588
  • 2
  • 20
  • 31
  • I'm sorry, I tried to make sense of what you wrote, but I don't really understand what you mean, especially by changing the menu type. – Lanbo Mar 02 '11 at 09:14
  • Ok, I'll explain. Every menu in Joomla has a type that you select when you create the menu. That determines what the menu link will display - which component and which view in the component. For Joomla articles, there are several different views that you can use depending on what you want to display. If you go in to edit the menu item for the section you are trying to display, there is a button that allows you to change the menu type. You should try changing your menu type to Articles >> Category >> Blog Layout. – Brent Friar Mar 02 '11 at 22:06
  • Thank you, that helped a bit. I have it now looking as I want it to, though it is probably not as intended by Joomla-creators. – Lanbo Mar 04 '11 at 07:31
  • That's the beauty of Joomla. The override system is designed so you can make Joomla look as you want not as the creators intend! With creative use of overrides you can do some pretty amazing things. – Brent Friar Mar 04 '11 at 13:16