Joomla template overrides: how to add image an description of the category and subcategories (catergories)

I’m playing a bit with template overrides, in templates/mytemplate/html/com_content/categories I have this file default_items.php that I want to modify so it will show image an description of the category that I’m in and I want the same for my subcategories on the same page.
If you check in this http://joomquery.com/templates/mytemplate/html/com_content/categories/default.php
you will see:

<?php if ($this->params->get('show_page_heading', 1)) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>

affter add:


<?php if ($this->params->get  ('show_description_image') && $this->parent->getParams()->get('image')) : ?>
<img src="<?php echo $this->parent->getParams()->get('image'); ?>" alt=" "/>
<?php endif; ?>

This code will show image for Main catergory, so some people want to add image to his all Subcatergories as blog layout.

please open http://joomquery.com/templates/mytemplate/html/com_content/categories/default_items.php

you will see:

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

Affter add:


<?php if ($this->params->get ('show_description_image') && $item->getParams()->get('image')) :?>
<img src="<?php echo $item->getParams()->get('image');?>" alt=" "/>
<?php endif; ?>

Try it now, goodluck.

Leave a comment