【问题标题】:Prestashop $category variable doesn't work within another ifPrestashop $category 变量在另一个 if 中不起作用
【发布时间】:2016-10-26 09:53:10
【问题描述】:

我使用 Prestashop,我需要在该类别的产品顶部为类别->id 1 添加一个特定的幻灯片,并且它需要在下面的代码中:

我尝试插入此代码:

{if category->id == '1'}
...
{/if}

在这段代码中:

{if isset($category)}
    {if $category->id AND $category->active}
        {if $scenes || $category->description || $category->id_image}
            ...
            {if $scenes}
                ...
                {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
                {if $category->description}
                    ...
                    {if Tools::strlen($category->description) > 350}
                        ...
                    {else}
                        {$category->description}
                    {/if}
                    ...
                {/if}
                ...
            {else}
                THERE'S WHERE I TRIED INSERT THE CODE
            {/if}
        {/if}
    {/if}
{/if}

不起作用..为什么?

问候,

【问题讨论】:

  • 从您的代码中不清楚,但最可能的原因是它在某个条件下的错误位置

标签: php smarty prestashop prestashop-1.6


【解决方案1】:

因为你放错了位置:)

{if isset($category)}
    {if $category->id AND $category->active}
        {if $scenes || $category->description || $category->id_image}
            ...
            {if $scenes}
                ...
                {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
                {if $category->description}
                    ...
                    {if Tools::strlen($category->description) > 350}
                        ...
                    {else}
                        {$category->description}
                    {/if}
                    ...
                {/if}
                ...
            {else}
                THERE'S WHERE I TRIED INSERT THE CODE (WRONG)
            {/if}
        {/if}
        THERE'S WHERE YOU HAVE TO PLACE THE CODE
        {if $category->id eq 1}
            /* some stuff */
        {/if}
    {/if}
{/if}

下次修复缩进,你自己达到目标;)

【讨论】:

    【解决方案2】:

    在最后一个之前插入

    {其他}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多