Jump to content

Hide Empty Categories in Prestashop 1.5.x


Recommended Posts

Hi community,

 

i got a new question that google isn`t able to answer so i hope you can.

 

I want empty categories not to be shown up in block categories. That should not be to

hard but my trys didn`t work, yet.

 

That can be done in Prestashop Backend but i have so many categories that i would prefere

this be done by code.

 

Found tutorials for older presta versions but they didn`t work for me.

 

Any ideas?

 

Thx a lot.

Link to comment
Share on other sites

Hey Vekia,

 

thanks for the fast help but that is exactly what i was trying before writing this post.

My code looked like that one from the tutorial and i controled several times. But empty categories still showin up.

 

Thx

Link to comment
Share on other sites

Hey Vekia,

 

sorry for bugging but i tried that tutorial 3 Times to make sure i didn`t make any mistakes. But still my empty categorys showing up.

If the file is the right one.

 

Here is my code similar to the on in the tutorial.

 

{if $node.products > 0}
<li {if isset($last) && $last == 'true'}class="last"{/if}>
    <a href="{$node.link|escape:'htmlall':'UTF-8'}" {if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|escape:'htmlall':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'} ({$node.products})</a>
    {if $node.children|@count > 0 && $node.products > 0}
        <ul>
        {foreach from=$node.children item=child name=categoryTreeBranch}
            {if $smarty.foreach.categoryTreeBranch.last}
                {include file="$branche_tpl_path" node=$child last='true'}
            {else}
                {include file="$branche_tpl_path" node=$child last='false'}
            {/if}
        {/foreach}
        </ul>
    {/if}
</li>
{/if}

 

I recompiled the template but nothing happend. I did a screenshot of the place where the category should not be shown if empty. This is not in the sidebar, it`s in the middle of the content.

 

Thx a lot for your help.

 

 

post-715146-0-70713100-1382429353_thumb.png

Link to comment
Share on other sites

plesae folow guides here: http://www.prestashop.com/forums/topic/277498-solved-how-to-display-total-product-numbers-at-the-end-of-each-category-name/?do=findComment&comment=1400777

 

(only step related to /modules/blockcategories/blockcategories.php file)

 

then use this in .tpl file:

{if $node.productsCount > 0}
<li {if isset($last) && $last == 'true'}class="last"{/if}>
    <a href="{$node.link|escape:'htmlall':'UTF-8'}" {if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|escape:'htmlall':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'} ({$node.products})</a>
    {if $node.children|@count > 0 && $node.products > 0}
        <ul>
        {foreach from=$node.children item=child name=categoryTreeBranch}
            {if $smarty.foreach.categoryTreeBranch.last}
                {include file="$branche_tpl_path" node=$child last='true'}
            {else}
                {include file="$branche_tpl_path" node=$child last='false'}
            {/if}
        {/foreach}
        </ul>
    {/if}
</li>
{/if}
Link to comment
Share on other sites

×
×
  • Create New...