Jump to content

[SOLVED] Categories Block: Disable Parent Category Links


Recommended Posts

I am trying to set up my categories block so that clicking on the Parent category causes the subcategories to drop down, and then clicking on the subcategory takes you to the product page.

As of now, I have all links disabled in the categories block, and I did this by following this post:

Hello,

Solution:

1st step - edit file 'category-tree-branch.tpl', located in yourshop/modules/blockcategories/

replace
{$node.name|escape:htmlall:'UTF-8'}


with

{$node.name|escape:htmlall:'UTF-8'}



2rd step - edit file'global.css', located in yourshop/themes/prestashop/css/

remove or comment classes

div#categories_block_left span.OPEN { 
       background: no-repeat left top url('../img/icon/less.gif'); 
}

div#categories_block_left span.CLOSE{ 
       background: no-repeat left top url('../img/icon/more.gif'); 
}

div#categories_block_left span.grower{
   display:block;
   float:left;
   background-position: 0px 3px;
   background-repeat: no-repeat;
   width:9px;
   height:15px;
   margin: 0 0 0 -10px!important;
   margin: 0 0 0 -6px;
   padding: 0;
}



Is there some sort of modification I can make to the LINK code (see below) so that only the subcategories behave as links?
{$node.name|escape:html:'UTF-8'} 




*EDIT*
Googled "prestashop node ids" and found this post. Looks like it might be my answer. Will try momentarily.

Try changing lines 9-13 of modules/blockcategories/blockcategories.tpl from:

{if $smarty.foreach.blockCategTree.last}
           {include file=$branche_tpl_path node=$child last='true'}
{else}
           {include file=$branche_tpl_path node=$child}
{/if}



to:

{if $smarty.foreach.blockCategTree.last}
           {include file=$branche_tpl_path node=$child depth=1 last='true'}
{else}
           {include file=$branche_tpl_path node=$child depth=1}
{/if}



then change line 2 of modules/blockcategories/category-tree-branch.tpl from:

<a href="{$node.link|escape:html:'UTF-8'}" {if $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|escape:html:'UTF-8'}">{/if}{$node.name|escape:html:'UTF-8'}{if $depth > 1}{/if}



to:

{if $depth > 1}<a href="{$node.link|escape:html:'UTF-8'}" {if $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|escape:html:'UTF-8'}">{/if}{$node.name|escape:html:'UTF-8'}{if $depth > 1}{/if}



and lines 6-10 of modules/category-tree-branch.tpl from:

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



to:

{if $smarty.foreach.categoryTreeBranch.last}
           {include file=$branche_tpl_path node=$child depth=$depth+1 last='true'}
{else}
           {include file=$branche_tpl_path node=$child depth=$depth+1 last='false'}
{/if}



Yep, this worked :)

Share this post


Link to post
Share on other sites
  • 1 month later...

Everything works perfect. Thanks. But there are 2 more things.

1. How to make all subcategories closed by default and make parent category to work like open/close button?

2. How to change SITEMAP and delete the links of parent category, because over there the PARENT category page still accesable?

Share this post


Link to post
Share on other sites
  • 6 months later...

Arrrrrr thanks indeed but it's not what you wanted in the first post & what we want !! Thanks for the help thought.

"sokpet" is right, it's almost the solution but to act like a tree-menu we need >> "How to make all subcategories closed by default and make parent category to work like open/close button?"

But thanks anyway, I will search further...

Share this post


Link to post
Share on other sites
  • 5 weeks later...
  • 6 months later...

Code below makes linkable only subcategories:

 

file: category-tree-branch.tpl

 

<li {if isset($last) && $last == 'true'}class="last"{/if}>

 

{if $node.children|@count > 0}

{$node.name|escape:htmlall:'UTF-8'}

<ul>

{foreach from=$node.children item=child name=categoryTreeBranch}

{if isset($smarty.foreach.categoryTreeBranch) && $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>

{else}

<a href="{$node.link}" {if isset($currentCategoryId) && ($node.id == $currentCategoryId)}class="selected"{/if} title="{$node.desc|escape:html:'UTF-8'}">{$node.name|escape:html:'UTF-8'}</a>

{/if}

</li>

Share this post


Link to post
Share on other sites
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More