문제

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}
도움이 되었습니까?

해결책

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}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top