0
votes

In Joomla 2.5.8, I've created a menu item that uses the "List All Categories" type. I'm wanting to display the image AND Title for the parent category and the images for each subcategory as follows:

-- Parent Category Image --

Parent Category Title Parent Category Description

SubCategory1 Title Subcategory1 Image -- SubCategory1 Description

SubCategory2 Title Subcategory2 Image -- SubCategory2 Description

SubCategory3 Title Subcategory3 Image -- SubCategory3 Description

SubCategory4 Title Subcategory4 Image -- SubCategory4 Description

I'm working in the file template/html/com_content/categories/default.php and I've tried copying the code from the blog.php file:

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

But it breaks the page and loads a blank page. The titles of the subcategories and their descriptions show, I'm just missing the parent title and the images.

In the options for the menu item I have the category title, description and image all set to show.

Any help on this would be greatly appreciated.

here's the deafault.php code:

<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_content
 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');

?>
<?php if ($this->params->get('show_page_heading')) : ?>
                <h1>
                    <?php echo $this->escape($this->params->get('page_heading')); ?>
                </h1>
                <?php endif; ?>
                <?php if ($this->params->get('show_base_description')) : ?>
                    <?php   //If there is a description in the menu parameters use that; ?>
                        <?php if($this->params->get('categories_description')) : ?>
                            <?php echo  JHtml::_('content.prepare', $this->params->get('categories_description'), '', 'com_content.categories'); ?>
                        <?php  else: ?>
                            <?php //Otherwise get one from the database if it exists. ?>
                            <?php  if ($this->parent->description) : ?>
                                <div class="category-desc">
                                    <?php  echo JHtml::_('content.prepare', $this->parent->description, '', 'com_content.categories'); ?>
                                </div>
                            <?php  endif; ?>
                        <?php  endif; ?>
                    <?php endif; ?>
                <?php
                echo $this->loadTemplate('items');
                ?>
2
We'll probably need more of the code from the override file to actually be able advise.Craig
I've edited the original with the code of the default.php file. I'm not needing the HTML/CSS framework to get the layout...I'm in need of the correct tags to have Joomla insert the MENU ITEM CATEGORY IMAGE, MENU ITEM CATEGORY TITLE and SUBCATEGORY IMAGES into this layout. I can see that there's a tag to get the parent description ($this->parent->description) so I tried doing ($this->parent->image) but it didn't work eitherlbweb

2 Answers

1
votes

The answer is here: http://forum.joomla.org/viewtopic.php?p=2613555

The codes to display the images, if the category has an image and if "Show category image" is selected (Joomla 2.5, it should work for 1.7 too).

For the parent category, in templates/mytemplate/html/com_content/categories/default.php

<?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; ?>

For the subcategories, in templates/mytemplate/html/com_content/categories/default_items.php

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

This is a solution for Joomla 3.x version. It works for both categories and sub-categories. templates/mytemplate/html/com_content/categories/default_items.php

<?php if ($item->getParams()->get('image')) : ?>
  <img src="<?php echo $item->getParams()->get('image');?>" alt="">
<?php end if; ?>