Elliot Alderson
Elliot Alderson

Reputation: 285

Prestashop $category variable doesn't work within another if

I use Prestashop and I need to add a specific slideshow for the category->id 1 on the top of the category's products, and it's need to be within the code below:

I tried to insert this code:

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

Within this code:

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

And it doesn't work.. why?

Regards,

Upvotes: 0

Views: 493

Answers (2)

marsaldev
marsaldev

Reputation: 3349

Because you have placed in wrong position :)

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

For the next time fix the indentation and you reach the goal by yourself ;)

Upvotes: 1

ventura
ventura

Reputation: 174

Insert it before the last

{else}

Upvotes: 1

Related Questions