| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Product is in these categories | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Product is in these categories
This was just a quick hack to get a result I needed for a product display page. It's messy and I'm sure someone will tidy it up and make it nice, but someone may be trying to do the same thing.
I have a selection of DVDs organised by studio using the manufacturer feature of X-Cart 4.0.15. Then my categories include things such as "comedy", "action", "thriller", etc. On the product display page I want a clickable graphic representation of the categories each DVD is in (comedy thriller, for example). So I put this quick botch in to product.php: Code:
In product.tpl I can now loop through $product_categories and use {$product_categories[loop].0} for each category id and {$product_categories[loop].1} for each category name. Or, in the case I'll be using it, .0 to provide an icon and href and .1 for the alt text. Hope that helps someone. Sorry it's so messy; I should probably use the correct variables for table/column names but .... YMMV. James.
__________________
www.affection.net |
|||||||
#2
|
|||||||
|
|||||||
Moving to Custom Mods, thanks for contributing!
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#3
|
|||||||
|
|||||||
sample code, please
Could you post exactly how to use this? I think this is what I have been trying to do but I couldn't figure out how to implement it.
Thanks
__________________
X-Cart version 4.1.10 upgraded from 4.0.13 myself slowly and with help from xcart forums. Thanks all! http://www.discountseforim.com Hebrew Seforim and Jewish Books |
|||||||
#4
|
|||||||
|
|||||||
Re: sample code, please
Quote:
This is a very quick and dirty solution which doesn't use the "xcart" way of creating database queries by using variable names, but it works. I inserted the following code at line 143 of "product.php": Code:
This selects all the categories that this product is in, unless they are parent categories, and assigns the array (where each row =array(category id, category name)) to Smarty as $product_categories. In skin1/customer/main/product.tpl I added an include to call my new ugly "categories.tpl" which in its most basic (and quite ugly) form looks like this: Code:
James. xx
__________________
www.affection.net |
|||||||
#5
|
|||||||
|
|||||||
Categories for product (Cleaned up & with nesting)
I have cleaned up and added to jamesc code to include sub category nesting(indenting). I used a spacer.gif for indenting but you can substitute with unordered list, character space, etc.
In product.php around line 143 insert the following: Code:
Now create a new template in the customer directory and call it "categories_for_selected_product.tpl" - this is just a modified "categories.tpl" file from the same directory. Include the following code: Code:
Now just include "categories_for_selected_product.tpl" in your customer/main/product.tpl.
__________________
Version 4.1.3 |
|||||||
#6
|
|||||||
|
|||||||
Thanks for this usefull mod!
Is it possible to see it somewehere in 'action'?
__________________
X-Cart 4.0.12 Heavy modified with paid, free and forum mods. PHP 5.2.5 | MYSQL 5.0.51a |
|||||||
#7
|
|||||||
|
|||||||
Quote:
Well thanks Jerrad but perhaps not so useful - just yet. There is a category sorting step(s) that needs to be added. In my test I put a sub-sub category into the very last sub category and it worked fine - it showed up where it should - at the end. Recently however when I entered a sub-sub category to a sub category in the middle of my list it also showed up at the end - since the defaut sort order for categories is the time they were added. One of the things I like about this code so far is that it only searches the catagory table once and then works with the array. I have a feeling that inorder to have nested subs with proper ordering it will require multiple (looped) searches of categories table - unless there is a way to cleverly reorder the array - that might be some involved programming though. Back to the drawing board.... Can anyone help? PS: I'll give you the URL to my store as soon as this is cleared up.
__________________
Version 4.1.3 |
|||||||
#8
|
|||||||
|
|||||||
I'm looking forward to your url, when you're finished at the drawingboard...
Thanks!
__________________
X-Cart 4.0.12 Heavy modified with paid, free and forum mods. PHP 5.2.5 | MYSQL 5.0.51a |
|||||||
#9
|
|||||||
|
|||||||
I think this is what I have been looking for... is that something like product advisor? I want to make something like the following link.
http://www.vitabase.com/tools/product-advisor.asp
__________________
Version 4.1.11 |
|||||||
|
|||
X-Cart forums © 2001-2020
|