Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Posts
    21
    Plugin Contributions
    0

    Idea or Suggestion Determining root category ID while in a sub-category [cPath question]

    Hi there,
    I need the help of a few Zen Cart guru's on this one. I know this can be done, but its just a little over the top of my head at this point (still learning).

    In short, I'm trying to alter the $categories_image variable (found in the tpl_index_categories.php template file) so that it'll only display the image from the root category (no matter how deep into the sub-categories of that main category you're in).

    So, for example, say I have the following category structure:

    Household Supplies [ID: 1]
    - Bathroom Supplies [ID: 2]
    --- Toilet Supplies [ID: 3]
    ------ Cleaners [ID: x]
    ---------- Clorox [ID: x]
    ---------- Windex [ID: x]

    ------ Seat Covers [ID: x]
    ---------- Fluffy [ID: x]
    ---------- Leather [ID: x]

    ------ Plungers [ID: x]
    ---------- Super-Mario Style [ID: x]
    --- Shower Supplies [ID: 4]
    ------ Curtains [ID: x]
    ---------- Pokadot [ID: x]
    ------ Shower Heads [ID: x]
    ---------- Steampunk [ID: x]
    etc

    Basically, I know the cPath to the 'Toilet Supplies' category would be 1_2_3, and 'Shower Supplies' would be 1_2_4.

    Now, my question is how would I go about pulling *just* the second number (first sub-category of the main category) out of that cPath?

    The goal here is so that the category icon for 'Bathroom Supplies' appears at the top of the 'Toilet Supplies' and 'Shower Supplies' category pages.

    I can probably figure out the rest from there ('if' situations to determine if we're more than 2 categories deep, etc), but I'm feeling a little stumped here. Any advice?


  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Determining root category ID while in a sub-category [cPath question]

    PHP Code:
    $path_ids explode('_',$_GET['cPath']);// break $cPath into array
    if (count($path_ids) >= 2) {//test for subcat level
      
    $path_firstsub $path_ids[1];// [1] is the second element in the array


  3. #3
    Join Date
    Dec 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: Determining root category ID while in a sub-category [cPath question]

    Quote Originally Posted by gjh42 View Post
    PHP Code:
    $path_ids explode('_',$_GET['cPath']);// break $cPath into array
    if (count($path_ids) >= 2) {//test for subcat level
      
    $path_firstsub $path_ids[1];// [1] is the second element in the array

    Glenn, I owe you a drink! Or two!

    I was completely over-analyzing the task at hand, thank you for simplifying it for me.

    Going to run with this for a bit, I think it'll do the trick. Thank you!

  4. #4
    Join Date
    Dec 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: Determining root category ID while in a sub-category [cPath question]

    Done deal, worked like a charm.

    Thanks again friend.

 

 

Similar Threads

  1. v151 Display images of Sub-Sub category in Main page while navigating.
    By Javier Romero in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 3 May 2013, 10:02 AM
  2. Replies: 1
    Last Post: 1 May 2013, 10:20 PM
  3. v151 Parent / Sub category question
    By jasperandjax in forum General Questions
    Replies: 11
    Last Post: 6 Nov 2012, 07:05 AM
  4. Strange sub category problem while browsing products
    By canemasters in forum General Questions
    Replies: 10
    Last Post: 31 Aug 2009, 06:54 AM
  5. sub category question...have searched.
    By skunkworx in forum General Questions
    Replies: 6
    Last Post: 21 Feb 2007, 08:53 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