Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Plugin Contributions
    0

    Default 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):

    Code:
    <?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. #2
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,268
    Plugin Contributions
    3

    Default Re: Get category parent ID

    Have you considered category-specific stylesheets...

    Read the README file in the classic template's css folder...
    20 years a Zencart User

  3. #3
    Join Date
    Jun 2007
    Posts
    62
    Plugin Contributions
    0

    Default 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!

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default 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.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

 

 

Similar Threads

  1. v154 How do I list products in sub category with in the parent category?
    By JoeToys in forum Setting Up Categories, Products, Attributes
    Replies: 38
    Last Post: 2 Dec 2018, 08:54 PM
  2. How to get content below subcategory listings on a parent category page
    By stoneroses6300 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 24 Jan 2013, 12:24 AM
  3. Replies: 7
    Last Post: 24 Nov 2012, 06:33 AM
  4. v139h How do I bulk-move all products from Sub-Category into a parent Category?
    By shags38 in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 28 Jun 2012, 07:19 PM
  5. Get parent id function
    By delia in forum General Questions
    Replies: 5
    Last Post: 3 Aug 2011, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg