如果,Prestashop $ category变量不能在另一个变量中起作用

时间:2016-10-26 09:53:11

标签: php smarty prestashop prestashop-1.6

我使用Prestashop,我需要为类别>产品顶部的category-> 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}

不起作用 ..为什么?

此致

2 个答案:

答案 0 :(得分:1)

在最后一次

之前插入

{别的}

答案 1 :(得分: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}

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