X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Targeting a whole Sub-Category with one if statement? (https://forum.x-cart.com/showthread.php?t=49527)

Mark UK 09-03-2009 01:04 PM

Targeting a whole Sub-Category with one if statement?
 
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.8)

Mark UK 09-04-2009 04:48 AM

Re: Targeting a whole Sub-Category with one if statement?
 
*bump*

cflsystems 09-04-2009 05:05 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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

Mark UK 09-04-2009 05:53 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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 :wink:

Thanks for your help!


http://img197.imageshack.us/img197/5682/subcat.jpg

amy2203 09-04-2009 05:58 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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.

cflsystems 09-04-2009 06:11 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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".

Mark UK 09-04-2009 07:07 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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 :D

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 :mrgreen:

ChristineP 09-04-2009 07:31 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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

amy2203 09-04-2009 07:34 AM

Re: Targeting a whole Sub-Category with one if statement?
 
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:

{if $extra_fields[0].fieldvalue eq "y"}
display tank mates bit
{/if}


there's lots on the forums about extra fields and if statemenmts,

hth

[/code]

amy2203 09-04-2009 07:36 AM

Re: Targeting a whole Sub-Category with one if statement?
 
oops!
posting at the same time! didn't see the last one 'till I was done!


All times are GMT -8. The time now is 02:37 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.