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

Displaying Extra Fields using "if" statements

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-17-2011, 06:07 AM
 
Fascinations Fascinations is offline
 

Member
  
Join Date: Dec 2010
Posts: 16
 

Default Displaying Extra Fields using "if" statements

I am trying to use extra fields on my product page. I want to be able to call each extra field individually in different locations and only show them if there is a "value" for that particular extra field.

For example: I have an extra field called "texture", it is the 3rd field from the top (so it is number "2"), below you will see the code I am using, it works just fine to show the field and it's value, but it doesn't go away when the field is left blank like I want it to. Does anyone have an idea what I am doing wrong here? Any feedback is appreciated. Thanks!

Code:
{section name=texture} {if $extra_fields[texture].active eq "Y" && $extra_fields[texture].field_value} <strong>{$extra_fields[2].field}:</strong> {$extra_fields[2].field_value} {/if} {/section}
__________________
X-Cart Pro 4.4
Reply With Quote
  #2  
Old 01-17-2011, 06:23 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,470
 

Default Re: Displaying Extra Fields using "if" statements

I've done something like this in XC 4.1.12 to control just one extra field:

Code:
{if $active_modules.Extra_Fields ne ""} {if $extra_fields[0].field_value eq "y"} *** Display your html/fields here *** {/if} {/if}

HTH
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #3  
Old 01-17-2011, 06:29 AM
 
Fascinations Fascinations is offline
 

Member
  
Join Date: Dec 2010
Posts: 16
 

Default Re: Displaying Extra Fields using "if" statements

If anyone else wants to accomplish something similar, I just figured it out.

The extra field number needed to be used in "if"statement as well.

This code works -
Code:
{section name=brand} {if $extra_fields[6].active eq "Y" && $extra_fields[6].field_value} <strong>{$extra_fields[6].field}:</strong> {$extra_fields[6].field_value} <br> {/if} {/section}
__________________
X-Cart Pro 4.4
Reply With Quote
  #4  
Old 01-20-2011, 07:00 AM
 
Sunray Sales Sunray Sales is offline
 

Senior Member
  
Join Date: Dec 2010
Posts: 194
 

Default Re: Displaying Extra Fields using "if" statements

Yes this code snippet was helpful, for some reason I was typing a similar code and it didn't work, I tried 6 variations of the code.

Then I just simply copied and pasted your code and it worked, then I finally modified it and everything works as expected.

Much appreciation to you for this! (Only took me 4 hours to get it work) :S LOL
__________________
4.4.2
www.sunraysales.com
HandsOnWebHosting
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 06:34 PM.

   

 
X-Cart forums © 2001-2020