joomlajoomla-template

Joomla show subcategory image on category page?


Is there a way, beside creating yet another MYSQL connection, to retrieve subcategory image while browsing parent category page?

For example:

Now, when i browse 'Main category', it display categories title and description of subcategories, but I cant find any 'normal' way to retrieve image that i set in basic option.

The only way that I can make to work is to create another MYSQL call and retrieve image from database, but I would like to know if there is another more effective way.

Im using Joomla 2.5.

Thanks!


Solution

  • I suggest you override the output of the content so that you can add some code to output your images.

    Copy:

    joomla/components/com_content/views/category/tmpl/blog_children.php

    To:

    joomla/templates/yourtemplate/html/com_content/category/blog_children.php

    Then edit your new override file, just below:

    <span class="item-title"><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id));?>">
        <?php echo $this->escape($child->title); ?></a>
    </span>
    

    Add:

    <div class="item-image">
        <?php echo '<img src="'.json_decode($child->params)->image . '" />'; ?>
    </div>
    

    See Joomla docs for Component Output Types and Layout Overrides.