Jump to content
Sign in to follow this  
keat

Hide category image

Recommended Posts

I have a small mod written by BSmither, where the first product image in a category is the one used by the category itself.

This works flawlessly.

However, If I have a sub category, then I have to assign an image manually. (not much of an issue)

Its when I have nested categories, (categories within categories) where I'm having a small issue.

Take a look at the following https://www.beal.org.uk/stainless-steel-cable-ties.html

And note how, when you're inside the category, that the manually assigned category image is shown above the sub categories.

Is there any way I can hide this image from this view.

Share this post


Link to post
Share on other sites

Every category has a parent category. Even the top-most categories have a "parent category ID" of "0".

So, if the category being shown has a parent category ID that is not "0", then it must be a sub-category. And if that is the case, you are wanting to suppress the display of any image - manually assigned or otherwise.

The admin can assign no image to the sub-categories, or
An edit to the code can be made in the PHP script, or
An edit can be made to the skin.

Please refer us to the prior work so that it can be determined if this edit can be put into effect at that location.

Share this post


Link to post
Share on other sites

As my sub cats may contain multiple products, in most cases, I'd like to be able to assign a manual image.

So If I could somehow supress the image from appearing at the top of the inside of the category, I think would be my preferred choice.

 

Note how fuses has a manual image applied https://www.beal.org.uk/electrical-products/fuses.html

and fuse holders doesn't https://www.beal.org.uk/electrical-products/fuse-holders-boxes.html

I don't believe that the image would cause any confusion, when in the fuses (sub, sub category,) but may do when in the category above.

https://www.beal.org.uk/fuses.html

 

As for the original mod, does this help.

 

 

 

Edited by keat

Share this post


Link to post
Share on other sites

I'm confused. The first sentence says you want to manually apply an image (and presumably show it). The second sentence you want to suppress displaying it.

Can you clear this up?

  • Like 1

Share this post


Link to post
Share on other sites

The images helps.

In admin, Manage Hooks, Code Snippets tab, click Add Snippet.

Enabled: Check
Unique_ID: if_subcat_suppress_cat_image
Execution Order: 1
Description: If viewing a subcat, then do not use it's image.
Trigger: class.cubecart.pre_display_category
Version: 1.0
Author: https://forums.cubecart.com/topic/54672-hide-category-image/
PHP Code:
<?php
  if(!empty($catData['cat_parent_id'])) { unset($catData['cat_image']); }

 

Share this post


Link to post
Share on other sites

Genius.

Thanks yet again Brian, it's perfect.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...