1

I'm trying to create a blog override to display all subcategories (of the current category) as a sort of secondary nav/filter, and and then display only the articles of the selected/active subcategory. I want the user to be able to jump between subcategories and see their articles without being directed to different pages, so I thought a special blog.php override would make the most sense.

What I'm trying to figure out is how to call the articles of a subcategory once the category is selected.

I understand that the

<?php foreach ($this->children[$this->category->id] as $id => $child): ?>

finds each subcategory, but I'm not sure how to access the articles of that subcategory.

2
  • I know your question from SO. What view you are trying to override? – FFrewin Sep 12 '14 at 16:00
  • I'm creating an override for blog.php. I moved the section that shows the children (subcategories) toward the top and would like to display their articles (items?) below, dynamically based on which subcategory is selected. – Annemarie Sep 12 '14 at 16:06
1

hmm... well you have the category id, so you could either directly call the articles from the database, or better use the Joomla Model to get the articles of each category, within the blog_children.php template.

$model = JModelList::getInstance('Articles', 'ContentModel', array('ignore_request'=>true));

$appParams = JFactory::getApplication()->getParams();
$model->setState('params', $appParams);
$model->setState('filter.category_id', $child->id);
$items = $model->getItems();


foreach ($items as $item) {
    echo "<div class='span12'>";
    echo $item->title;
    echo "</div>";
}

Hope this will take you closer to what you want achieve.

2
  • Thank you so much for taking the time to respond! I'm still pretty new to Joomla development so it will take some playing around with but I really appreciate your help. – Annemarie Sep 12 '14 at 20:26
  • Does not work in the module helper file – Jimmy Obonyo Abor Dec 23 '15 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.