Reputation: 8572
Is it possible to define a variable within an Expression Engine template? If so, how might one go about doing so?
Take the following use case as an example. I'm looking for the proper method for defining the value of the primary_image_found
variable.
{primary_image_found = False}
{product_images}
{if primary_image_found == False and sm_img == ''}
{primary_image_found = True}
<img src="{lg_img}" />
{/if}
{/product_images}
Upvotes: 0
Views: 57
Reputation: 1450
I think you are looking for Preload Text Replacements perhaps?
Define and use a variable for "channels":
{preload_replace:channels="news|reviews"}
{exp:channel:category_heading channel="{channels}"}
<h1>{category_name}</h1>
{if category_description != ""}<p>{category_description}</p>{/if}
{/exp:channel:category_heading}
{exp:channel:entries channel="{channels}" limit="10"}
<h2>{title}</h2>
{body}
{/exp:channel:entries}
Upvotes: 1