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)
-   -   Displaying Extra Fields using "if" statements (https://forum.x-cart.com/showthread.php?t=57561)

Fascinations 01-17-2011 06:07 AM

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}


chamberinternet 01-17-2011 06:23 AM

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

Fascinations 01-17-2011 06:29 AM

Re: Displaying Extra Fields using "if" statements
 
If anyone else wants to accomplish something similar, I just figured it out. :mrgreen:

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}


Sunray Sales 01-20-2011 07:00 AM

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


All times are GMT -8. The time now is 12:28 PM.

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