Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Get category parent ID

Get category parent ID

Locked

Views: 4,099

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
2 May 2008, 5:13 PM
#1
karl19 avatar

karl19

New Zenner

Join Date:
Jun 2007
Posts:
62
Plugin Contributions:
0

Get category parent ID

Hi there,

We've got a page where we're showing the category image as a header. We're using standard ZC code (tpl_index_categories.php):

<?php
if (PRODUCT_LIST_CATEGORIES_IMAGE_STATUS_TOP == 'true') {
// categories_image
  if ($categories_image = zen_get_categories_image($current_category_id)) {
?>
<?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT); ?>
<?php
  }
} // categories_image
?>
```If we're in a main category, it's showing one image; if in a sub-category, it's showing another image. However, I would like to show the main category image even when in a sub-category, as we're using the sub-category image slightly differently.

So in essence, whether you're in a main category or one of its sub-categories, it should always output the image associated with the main category. Is this possible? I thought something like **$parent_category_id** would work, but doesn't seem to.

Happy for any help on this. The site is not live yet, so unfortunately can't add a URL.

Thanks, Karl
2 May 2008, 5:24 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Get category parent ID

Have you considered category-specific stylesheets...

Read the README file in the classic template's css folder...

5 May 2008, 7:43 AM
#3
karl19 avatar

karl19

New Zenner

Join Date:
Jun 2007
Posts:
62
Plugin Contributions:
0

Re: Get category parent ID

Thanks for the reply schoolboy,

since the images needed are the ones uploaded for categories in the admin, using css for this probably wouldn't be the way to go. The person who will be updating the site needs to be able to change the image in the admin, rather than in a stylesheet.

Still haven't found a solution to this, though I think it should be possible. One would need a code-snippet addition to the image-listing function, which checks if the category is a sub-category, then make it revert to its main category. Which would make it output the main category image.

..but that's theory. How one would write that snippet, I don't know!

5 May 2008, 7:56 AM
#4
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Get category parent ID

I believe there is a function that does that, look in:
includes/functions/functions_categories.php to see if you can use any function in there.