How to display subcategory images on category page

  • Posts: 3
  • Thank you received: 0
10 years 1 week ago #213607

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.4.41

I tried to edit the category listing_div.php to add subcategory images instead of the subcategory name below the current category. But I can't figure out how to get there.

This is what I already have, but I can't get the image of the subcategory:

<?php
$image_options = array('default' => true,'forcesize' => $this->config->get('image_force_size', true),'scale' => $this->config->get('image_scale_mode', 'inside'));

$img = $this->image->getThumbnail(@$this->row->file_path, array('width' => $this->image->main_thumbnail_x, 'height' => $this->image->main_thumbnail_y), $image_options);
                            
if($img->success) 
{
    echo '<img class="hikashop_product_listing_image" title="'.$this->escape(@$this->row->file_name).'" alt="'.$this->escape(@$this->row->file_name).'" src="'.$img->url.'" width="60px" height="35px" />';
}
                            
/*
echo $child->category_name;

if($this->params->get('number_of_products',0))
{
    echo ' ('.$child->number_of_products.')';
}
*/
?>

Can someone please help me with this?

Thank you very much!

Please Log in or Create an account to join the conversation.

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
10 years 1 week ago #213615

Hi,

You can just use a more appropriated layout for the category listing ; like the "img title" one which display the category images directly.
www.hikashop.com/support/documentation/i...-menus-form.html#div

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
10 years 6 days ago #213693

Thank you Jerome for the quick response on this.

But configure the category listing, I get the subcategories below all main categories. I like to get the subcategory images below each main categorie, illustrated in the attachment. I think it must be possible because hikashop is such a flexible system, but I can not figure out how.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 84305
  • Thank you received: 13700
  • MODERATOR
10 years 6 days ago #213718

Hi,

It's indeed the listing_div file of the category view that you want to edit.
There you will have first to load the images of the sub categories from your MySQL database with a MySQL query on the hikashop_file table. Then, you'll be able to use PHP code similar to what you have on your first post to display the images instead of their name.

The following user(s) said Thank You: spavanes

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum