Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Targeting a whole Sub-Category with one if statement?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-03-2009, 01:04 PM
 
Mark UK Mark UK is offline
 

Member
  
Join Date: Jul 2009
Posts: 17
 

Question 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.
__________________
X-Cart Gold Version 4.2.1
Reply With Quote
  #2  
Old 09-04-2009, 04:48 AM
 
Mark UK Mark UK is offline
 

Member
  
Join Date: Jul 2009
Posts: 17
 

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

*bump*
__________________
X-Cart Gold Version 4.2.1
Reply With Quote
  #3  
Old 09-04-2009, 05:05 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #4  
Old 09-04-2009, 05:53 AM
 
Mark UK Mark UK is offline
 

Member
  
Join Date: Jul 2009
Posts: 17
 

Default 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

Thanks for your help!


http://img197.imageshack.us/img197/5682/subcat.jpg
__________________
X-Cart Gold Version 4.2.1
Reply With Quote
  #5  
Old 09-04-2009, 05:58 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default 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.
__________________
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!
Reply With Quote
  #6  
Old 09-04-2009, 06:11 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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".
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 09-04-2009, 07:07 AM
 
Mark UK Mark UK is offline
 

Member
  
Join Date: Jul 2009
Posts: 17
 

Default 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

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
Reply With Quote
  #8  
Old 09-04-2009, 07:31 AM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default 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
__________________
______________
version 4.1.9 Gold
Reply With Quote
  #9  
Old 09-04-2009, 07:34 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default 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]
__________________
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!
Reply With Quote
  #10  
Old 09-04-2009, 07:36 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default 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!
__________________
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!
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020