1

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

For example:

  • Main category (set as category as blog)
    • Subcategory 1 (image set in Basic options image field)
    • Subcategory 2 (image set in Basic options image field)
    • Subcategory 3 (image set in Basic options image field)
    • ....

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!

RhymeGuy
  • 2,102
  • 5
  • 32
  • 62

1 Answers1

7

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.

Matteus Hemström
  • 3,796
  • 2
  • 26
  • 34