| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Targeting a whole Sub-Category with one if statement? | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() Hi all,
I have a unordered list that I want to show on all product pages under a certain sub-category, I'm using this if statement: {if $current_category.parentid == 258 or $current_category.parentid == 259 or $current_category.parentid == 261 or $current_category.parentid == 262 or $current_category.parentid == 271 or $current_category.parentid == 272 or $current_category.parentid == 251 or $current_category.parentid == 306 or $current_category.parentid == 307 or $current_category.parentid == 308} This works fine when targeting the sub-category, sub-sub-category & then product, but then I have to make a load more '$current_category.parentid' statements if I want to target sub-sub-sub-category products, and this will be quite a list with the amount of sub-sub-categorys I got! Is there an easier way of doing this? In a nutshell I want to be able to target all in red with one statement. Tropical (ROOT) -Tropical Fish (SUB-CATEGORY) -African Cichlids (SUB-SUB-CATEGORY) -Misc Cichlids (SUB-SUB-SUB-CATEGORY) -Buttikoferi cichlid(PRODUCT) -Nyererei cichlid(PRODUCT) -Zebra obliquidens (PRODUCT) -Tanganyikan Cichlids (SUB-SUB-SUB-CATEGORY) -Malawi Cichlids (SUB-SUB-SUB-CATEGORY) -American & New World Cichlids (SUB-SUB-CATEGORY) -Tropical Invertebrates (ROOT) -Plants (ROOT) -Tropical Tank Cleaners (ROOT) Thank you for your time and help, Mark. ![]()
__________________
X-Cart Gold Version 4.2.1 |
|||||||
#2
|
|||||||
|
|||||||
![]() *bump*
__________________
X-Cart Gold Version 4.2.1 |
|||||||
#3
|
|||||||||
|
|||||||||
![]() You want to show it on product detail page correct? Then just add an extra field with value of 'y' or 'n', fillout for each product and in product.tpl check this filed - if it's 'y' then show text
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#4
|
|||||||
|
|||||||
![]() Hi Steve,
Thing is I'm not using fields, the unordered list is hardcoded into the product page using if statements to show and not show, also using this method to show a box below called tank mates. I'm trying to find a easier way of saying if all products are under one subcategory, show list and tank mates. At the moment I'm using the above code which works well with first chain of sub-category, sub-sub-category, but if my client adds a new sub-sub-sub category I have to go in manually and add '$current_category.parentid == 258' for each sub-sub-sub category. I was hoping to find a statement that say's 'all under this sub-category is allowed' type of deal. Hope that all makes sense, first X-Cart site so I'm still learning ![]() Thanks for your help! http://img197.imageshack.us/img197/5682/subcat.jpg
__________________
X-Cart Gold Version 4.2.1 |
|||||||
#5
|
|||||||||
|
|||||||||
![]() It would probably be easier to check for the data than to check for the parent category, so if there are any 'Tank Mates' diaply it, if not don't.
I take it the 'Tank Mates' are the upselling products, so do an if there are any.
__________________
X-Cart version 5 (Previously 3.5-4) Previous Versions included BCSE Reward Points Mod Altered Cart On Sale Mod Wordpress Plugin Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there. Shout me a Coffee! |
|||||||||
#6
|
|||||||||
|
|||||||||
![]() The extra field will serve as a flag if you want to show or not the list and tank mates. They will be hard coded in the product.tpl but will only show if the flag is "Y".
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#7
|
|||||||
|
|||||||
![]() Ahh.. okay, so I add an extra field to the product page like 'Show List A' Y/N and that an if statement to the actual product.tpl. Great, I understand where you two are coming from, makes much more sense to come from product data
![]() My only problem is the if statement for fields on product page, would you be so kind as to give me an example of this code? like a simple if yes display 'hello' if not display 'goodbye' or something like that? again I'm not overly familiar with smarty code yet. Thank you so much for you time, much appreciated Steve and Amy ![]()
__________________
X-Cart Gold Version 4.2.1 |
|||||||
#8
|
|||||||
|
|||||||
![]() I have this working in 2 separate areas of my product.tpl. Below is an example and you can see more at: http://forum.x-cart.com/showthread.php?t=25143 (post #20 - #26).
example: {section name=field loop=$extra_fields} <div id="download">{if $extra_fields[field].service_name eq "products_PDF" && $extra_fields[field].field_value ne ""}{include file="modules/Extra_Fields/document_icon.tpl"} {/if}</div> <div id="download">{if $extra_fields[field].service_name eq "products_manual" && $extra_fields[field].field_value ne ""}{include file="modules/Extra_Fields/document_icon.tpl"} {/if}</div> {/section} I also have this working within our tabs. Christine
__________________
______________ version 4.1.9 Gold |
|||||||
#9
|
|||||||||
|
|||||||||
![]() it will depend on your extra frields set up, how many you've got, which one you want etc, but you'll need something along the lines of
Code:
there's lots on the forums about extra fields and if statemenmts, hth [/code]
__________________
X-Cart version 5 (Previously 3.5-4) Previous Versions included BCSE Reward Points Mod Altered Cart On Sale Mod Wordpress Plugin Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there. Shout me a Coffee! |
|||||||||
#10
|
|||||||||
|
|||||||||
![]() oops!
posting at the same time! didn't see the last one 'till I was done!
__________________
X-Cart version 5 (Previously 3.5-4) Previous Versions included BCSE Reward Points Mod Altered Cart On Sale Mod Wordpress Plugin Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there. Shout me a Coffee! |
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|