Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Display Parent Category Image on Listings Page

Display Parent Category Image on Listings Page

Locked

Views: 1,973

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
7 Aug 2008, 4:51 PM
#1
ryandot avatar

ryandot

New Zenner

Join Date:
Aug 2008
Location:
Fermanagh, Ireland
Posts:
3
Plugin Contributions:
0

Display Parent Category Image on Listings Page

Hi i want to display the parent/top category image on the product listing page instead of the sub category image, is this possable?

p.s i can't use the same image for both the parent and sub category.

i hope this makes sense!

7 Aug 2008, 4:52 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Parent Category Image on Listings Page

You could reference the parent category by checking the categories table for the parent_id and then obtain that image ...

7 Aug 2008, 6:42 PM
#3
ryandot avatar

ryandot

New Zenner

Join Date:
Aug 2008
Location:
Fermanagh, Ireland
Posts:
3
Plugin Contributions:
0

Re: Display Parent Category Image on Listings Page

hi Ajeh i should have mentioned i have very little programming experience, how would i go about doing that?

8 Aug 2008, 1:48 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Parent Category Image on Listings Page

You would have to clean this up but if you look in the tpl_index_product_list.php you can see where I insert a quick peice of code to grab the image and display it:

<?php
if (PRODUCT_LIST_CATEGORIES_IMAGE_STATUS == 'true') {
// parent image
$check_categories_parent_id = $db->Execute("SELECT parent_id FROM " . TABLE_CATEGORIES . " WHERE categories_id='" . $current_category_id . "'");
$catgories_parent_image = zen_get_categories_image($check_categories_parent_id->fields['parent_id']);
?>
<div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $catgories_parent_image, '', CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT); ?></div>
<?php

// categories_image
  if ($categories_image = zen_get_categories_image($current_category_id)) {
?>
<div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT); ?></div>
<?php
  }
} // categories_image
?>

See if that helps get you started ...

8 Aug 2008, 3:53 PM
#5
ryandot avatar

ryandot

New Zenner

Join Date:
Aug 2008
Location:
Fermanagh, Ireland
Posts:
3
Plugin Contributions:
0

Re: Display Parent Category Image on Listings Page

Thanks Ajeh that worked perfect for me, thank you!!