I have a custom layout for mod_articles_category. I am trying to add the Category link outside that this Articles Category item links to, but outside of the loop of $items.

I have tried this, but had no luck:

<div class="container text-center">
    <h2><a href="<?php echo $list->displayCategoryLink; ?>" title="Luxton Testimonials">What they say</a></h2>
    <?php echo print_r($list); ?>

How do I get the category link that is available in the article loop with $item->displayCategoryLink; but outside of the actual article loop, for a heading?

  • Is it showing articles from 1 only category?
    – FFrewin
    Feb 26, 2015 at 20:57
  • It's not very clear what you are trying to achieve. Maybe a little bit clearer description of what you have in mind and the desired outcome would help.
    – FFrewin
    Feb 26, 2015 at 21:16
  • So I have a custom layout for articles and do some logic in the for each loop. But I am trying to get the category link (this is for only one category) outside of the forloop. Before the forloop I have a header and I want that to link to the category.
    – StuartM
    Feb 26, 2015 at 21:20
  • since it will be 1 category - you can grab the category from the first article in the module - check in my answer below.
    – FFrewin
    Feb 26, 2015 at 21:22

2 Answers 2


It's not very clear what you are trying to do.
This module can display articles from many categories and also works in various modes.

In the case of multiple categories, what is the one that you will display as heading?

At the other hand, there is no such thing as $list->displayCategoryLink;

Anyway, in the case you show articles from 1 only category, and you want to get the link of that category outside of the loop, to use it in anyway you want, you can access the link of the first item of the list like this:

  • Thanks @FFewin, you are correct I just need to access the first item in the array and use that link. Thanks for this!
    – StuartM
    Feb 27, 2015 at 9:16

Joomla by default uses $item-> instead of $list-> to make sure your foreach loop looks like this:

foreach ($SOME_VARIABLE as $list){
   // code here

Which will mean the following will work.


If that's what you already have, then go to:

Joomla backend >> Module Manager >> Articles Category >> Display Options (tab)

Then set Category to Yes else the category for each article won't display ;)

Hope this helps

  • Thanks, Category is already set to Show in the module. Neither $item or $list works. Please note, per the question this is outside of the foreach loop itself, its before it within the custom layout. Thanks
    – StuartM
    Feb 26, 2015 at 19:20
  • I think the specific here is that its outside of the loop that I need to access that variable.
    – StuartM
    Feb 26, 2015 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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