| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Subcategories: reference to parentid | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() Pardon my newbieness - just getting started w/x-cart...
I'm trying to do a conditional in customer/categories.tpl and need to detect current subcategory's parent id. I've seen references in the forums to $current_category.parentid but this isn't working for me (it's null). Is there a mod I need to make to the query for $categories_data in include/categories.php to include the parent info? I don't see anything in there for parent. Thanks!
__________________
------------------ ~Gregg X-Cart 4.0.12 Apache 1.3.33 mySQL 4.0.22 PHP 4.3.10 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() I think what you are reading is for 4.0.x In 3.x you will need to do some php manipulation to get the data you want. You'll need to parse the category name to find the parent category name, then get the category id from there.
For example if you have this category: Quote:
Quote:
To get that in php you'll need to use one (or more!) of the php string functions. Once you have the parent category name, you can select from the mysql the parent categoryid. I hope that makes sense. I did some interesting parent category manipulation in this thread: http://forum.x-cart.com/viewtopic.php?t=11857&postdays=0&postorder=asc&hig hlight=categories&start=15 Hope that helps you get started! Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002! We support X-cart versions 3.x through 5.x! Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more! Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com Please E-Mail us for questions/support! |
|||||||||
#3
|
|||||||
|
|||||||
![]() Welcome Gregg. Please read the forum rules and descriptions prior to posting. I have deleted your other post in the Custom Mods section. That is for completed mods only, not questions. Also, please don't double post. Thanks!
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#4
|
|||||||
|
|||||||
![]() Thanks folks. I've now ugraded to 4.0.12 so I can detect on
$current_category.parentid Once detected though, I want to display the siblings - the parent category's children. In other words, subcats should display at both levels - standard expand/collapse behavior. Whether in Animals section or Cats, display: Code:
When in parent (Animals) I can use: {section name=subcat_num loop=$subcategories} That works fine. I'm having trouble with displaying siblings. How do I reference the parent's subcategories? This doesn't work: {section name=subcat_num loop=$categories[cat_num].subcategories}
__________________
------------------ ~Gregg X-Cart 4.0.12 Apache 1.3.33 mySQL 4.0.22 PHP 4.3.10 |
|||||||
#5
|
|||||||
|
|||||||
![]() I've got it worked out. Here's the code:
Code:
__________________
------------------ ~Gregg X-Cart 4.0.12 Apache 1.3.33 mySQL 4.0.22 PHP 4.3.10 |
|||||||
#6
|
|||||||
|
|||||||
![]() Thanks for sharing this solution! Question on the fragment below:
Quote:
Please excuse if the question's answer is obvious, but I can't determine why this bit causes display of the subcats in alphabetical order while viewing one of said subcats. Is there a modification which can be made to keep the subcats in preset order (as determined in the admin area)? Thanks, Paul
__________________
Paul Mc 4.0.12 Pro Dedicated Linux Server |
|||||||
|
|||
X-Cart forums © 2001-2020
|