Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

parent categories listed horizontally, ONLY sub-cats of the parent listed on the left...?


Tabula_Rasa

Recommended Posts

Posted

I'm trying to modify osCommerce to adhere to a design developed by a designer unfamiliar with application. For the most part, everything is going well, but I'm stuck with one design feature that, for some reason, I can't wrap my head around for a solution.

 

Problem: The 3 parent categories are listed at the top of the site, horizontally. Based on the parent category that's "active," Only the sub- and sub-sub- categories for THAT parent are listed on the left.

 

Complications:

(1) I've stripped Tablele tags from osC and made the site tableless without using templates. The closest contribution for category boxes at ALL was UL_Categories, which created nested unordered lists.

(2) I'm using Ultimate SEO URL's, complicating my ability to just add a $_GET parameter to say what the parent is.

(3) I'm assuming, in application_top.php, that the solution is to traverse the tree upward to discover what the 0 parent category is, then based on that, list the sub-categories... starting a new nested UL when a sub-category, itself, has sub-categories.

(4 - bonus) Since that's a lot of query calls for a category box, if there's a way to cache the 3 types of boxes... ;)

 

I'd love some help on this. At LEAST pointing me to the method of determining the root parent for any given product_info.php or sub-category...

 

Thanks!!

Posted

$parent_category = (isset($cPath_array) && (sizeof($cPath_array) > 1)) ? (int)$cPath_array[sizeof($cPath_array) - 2] : (int)$current_category_id ;

echo $parent_category;

 

That would work on pages that use the $cPath_array

Posted

$parent_category = (isset($cPath_array) && (sizeof($cPath_array) > 1)) ? (int)$cPath_array[sizeof($cPath_array) - 2] : (int)$current_category_id ;

echo $parent_category;

 

That would work on pages that use the $cPath_array

 

I came out with something similar (haven't added the isset stuff, yet, but...):

 

$cPath_array[0]

Posted

$cPath_array[0] gets the first value of the cPath array.

 

If you therefore have this (example):

 

cPath=1_2_3

 

Your [0] = 1 (the parent of 2, and the grandparent of 3)

My code = 2 (the parent of 3)

 

and if you had this:

 

cPath=1_2_3_4

 

Your [0] = 1 (the parent of 2, and the grandparent of 3, great-grandparent of 4)

My code = 3 (the parent of 4)

 

Anyway, you can play with whatever code you like to get the result desired.

  • 1 month later...
Posted

great code burt... thanks

 

However when i use this code it spits out the id number of the category.. is there a way to modify your code to return the NAME of the category? I would really appreciate it! sorry for my lack of coding knowledge I've been trying to modify your code but cant get it

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...