View Single Post
  #6  
Old 11-02-2012, 02:22 AM
  David-Allan's Avatar 
David-Allan David-Allan is offline
 

eXpert
  
Join Date: Oct 2011
Location: Scotland, UK
Posts: 313
 

Default Re: Extra Fields if statement

Quote:
Originally Posted by carpeperdiem
THIS is NOT TESTED SPECIFICALLY, but based on code that works. This should get you started.

1. verify the extra field content is available on your page (use webmaster mode)
2. define a variable, $test for the extra field, "testing". The if code makes sure there is something there, else it ignores.

Code:
{section name=field loop=$extra_fields} {if $extra_fields[field].field eq "testing" && $extra_fields[field].field_value ne ""} {assign var="test" value=$extra_fields[field].field_value} {/if} {/section}

3. place your variable in a div with inline css. The if makes sure something is there, else it ignores. If $test is empty, nothing happens. If test has something in it, it will display the <div> - which is set to not display anything using css, style="display:none;"

Code:
{if $test ne ""} <div style="display:none;">TESTING CONTENT GOES HERE</div> {/if}

The logic is: "is there anything in the test field? If so, do not display the content.

Hope this helps in some way.

J

J your some man that works a treat with some tweaking.

Here is what I did incase it helps anyone else.

Code:
{section name=field loop=$extra_fields} {if $extra_fields[field].field eq "Sample Request" && $extra_fields[field].field_value ne ""} {assign var="test" value=$extra_fields[field].field_value} {/if} {/section} {if $test ne ""} <div style="display:none;"> {include file="customer/buttons/button.tpl" button_title=$lng.lbl_ask_question_about_product style="link" href="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=`$product.productid`')"} </div> {else} <div class="ask-question"> {include file="customer/buttons/button.tpl" button_title=$lng.lbl_ask_question_about_product style="link" href="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=`$product.productid`')"} </div> {/if}
__________________
Live Version : 4.5.2
Licensed Products:
X-Cart Gold
Ability Theme
CDSEO
xCMS
Abandoned Cart
Food Packaging Scotland
Reply With Quote