View Single Post
  #7  
Old 03-07-2009, 01:41 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: extra fields, assigning a variable, using more than one extra field

This works. Thanks.

IT APPEARS that a variable is only good for the template it is created on, and nested templates.

HOWEVER, you can't use an include to an outside template to make your variables.

For example, this code in the top of product.tpl makes a bunch of variables, that can be used on product.tpl, and any other templates nested in it:

Code:
{section name=field loop=$extra_fields} {if $extra_fields[field].field eq "Ingredients" && $extra_fields[field].field_value ne ""} {assign var="ingred" value=$extra_fields[field].field_value} {/if} {if $extra_fields[field].field eq "videocontent" && $extra_fields[field].field_value ne ""} {assign var="videocon" value=$extra_fields[field].field_value} {/if} {if $extra_fields[field].field eq "videocontenttitle" && $extra_fields[field].field_value ne ""} {assign var="videocontitle" value=$extra_fields[field].field_value} {/if} {if $extra_fields[field].field eq "videocontentdescription" && $extra_fields[field].field_value ne ""} {assign var="videocondesc" value=$extra_fields[field].field_value} {/if} {if $extra_fields[field].field eq "videocontentimage" && $extra_fields[field].field_value ne ""} {assign var="videoconimg" value=$extra_fields[field].field_value} {/if} {/section}

However, if were to extract this code, call it extra_field_vars.tpl, and then do an include from product.tpl, it will not work. CAN SOMEONE VERIFY THIS IS CORRECT? Doesn't make sense, but this is what is happening.

From there, I can go to town. This function allows me to upload about 25 videos via csv instead of manually editing 25 templates (and having to deal with a different template per product, when it's not needed).

Thanks for sticking around to help me on this. I owe you one.

Best,

Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote