在模板中定义变量

时间:2014-03-11 18:39:41

标签: php expressionengine

是否可以在Expression Engine模板中定义变量?如果是这样,那怎么可能这样做呢?

以下面的用例为例。我正在寻找定义primary_image_found变量值的正确方法。

{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}

1 个答案:

答案 0 :(得分:1)

我认为您正在寻找Preload Text Replacements

为“渠道”定义并使用变量:

{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}