Jump to content

Exclude a specific category from Categories Block


Recommended Posts

great!

 

here is the code:

{if $node.id != 20}
<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|strip_tags|trim|escape:'htmlall':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'}</a>
	{if $node.children|@count > 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}

code above {if $node.id != 20} means:

if category id is different than 20, then display link.

so the category with id will be hidden.

  • Like 2
Link to comment
Share on other sites

  • 8 months later...

great!

 

here is the code:

{if $node.id != 20}
<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|strip_tags|trim|escape:'htmlall':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'}</a>
	{if $node.children|@count > 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}

code above {if $node.id != 20} means:

if category id is different than 20, then display link.

so the category with id will be hidden.

 

What if we want to exclude more than one category?

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...
  • 4 weeks later...

Hi, and thank you for your post

 

UP for 1.6

 

I would like authorised only one category from categories block

 

OR

 

I would like masked specific category  from categories block

 

any one ?

 

many thanks

 

regards

I would like to know this as well... Trying to exclude two categories from the category block in 1.6.0.9.

 

P.S: Figured it out .

Edited by Loonary (see edit history)
Link to comment
Share on other sites

  • 2 months later...

Hey i want to remove image from one category and display images for all other category..How can i do that?i brought the images to block category left.i want to remove the image from one category from there.

 

what is your code at the moment? can you show it ?

+ for what category (id) you want to disable these images? by images you mean cateogry heading image?

Link to comment
Share on other sites

Hi Vekia

 

<li {if isset($last) && $last == 'true'}class="last"{/if}>
    <a
    href="{$node.link|escape:'html':'UTF-8'}"{if isset($currentCategoryId) && $node.id == $currentCategoryId} class="selected"{/if} title="{$node.desc|strip_tags|trim|escape:'html':'UTF-8'}"><img src="{$link->getCatImageLink($category->link_rewrite, $node.id)}"/>
    
        {$node.name|escape:'html':'UTF-8'}
    </a>
    {if $node.children|@count > 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>

 

This is my category-tree-btanch.tpl and the underlined part is the code i added to bring the category image to the category block left. But currently 'categories with no image added' is displaying thumbnail with no image.i have attached that image with this. so i want to write a conditon so that if no image is added to the category only the category name should be shown and the thumbnail is not shown.

 

hope u understand the problem .Pls help me

Sorry im not able to upload that image an error msg is coming.I hope u got what i meant with the thumbnail with no image.

Link to comment
Share on other sites

HI vekia..

I have attached a screen shot of my page with this.In that in category block there is no image added to category giftcard.but its displaying a thumbnail like that.I want to remove that. I want a general if condition so that if no image is added to category it shouldnot display a thumbnail like that.post-895020-0-15130200-1422597882_thumb.png

 

I am not using a customized version.the images added to a category from backoffice is displayed there in the category block.The code for that is in my yesterday's post. Pls help

Edited by neerajlm10 (see edit history)
Link to comment
Share on other sites

  • 7 months later...

Hi everyone, my solution for Prestashop 1.6.x  si here:

 

1. I created 3 categories (with id 80, 81 and 82 as well)

 

2. I edited some lines in blockcategories.tpl file like this:

 

This:

<div class="block_content">
   <ul class="tree {if $isDhtml}dhtml{/if}">
      {foreach from=$blockCategTree.children item=child name=blockCategTree}
         {if $smarty.foreach.blockCategTree.last}
            {include file="$branche_tpl_path" node=$child last='true'}
         {else}
            {include file="$branche_tpl_path" node=$child}
         {/if}
      {/foreach}
   </ul>
</div> 

To this:

<div class="block_content">
   <ul class="tree {if $isDhtml}dhtml{/if}">
      {foreach from=$blockCategTree.children item=child name=blockCategTree}
         {if $child.id !=80}
            {if $child.id !=81}
               {if $child.id !=82}
                  {if $smarty.foreach.blockCategTree.last}
                     {include file="$branche_tpl_path" node=$child last='true'}
                  {else}
                     {include file="$branche_tpl_path" node=$child}
                  {/if}
               {/if}
            {/if}
         {/if}
      {/foreach}
   </ul>
</div> 

Shape {if $child.id !=80 || $child.id !=81 || $child.id !=82} didnt work for me, but you can try it ;)

 

This is not total cosher solution, but absolutly works ;) 

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 6 months later...

Hi everyone, my solution for Prestashop 1.6.x  si here:

 

1. I created 3 categories (with id 80, 81 and 82 as well)

 

2. I edited some lines in blockcategories.tpl file like this:

 

This:

<div class="block_content">
   <ul class="tree {if $isDhtml}dhtml{/if}">
      {foreach from=$blockCategTree.children item=child name=blockCategTree}
         {if $smarty.foreach.blockCategTree.last}
            {include file="$branche_tpl_path" node=$child last='true'}
         {else}
            {include file="$branche_tpl_path" node=$child}
         {/if}
      {/foreach}
   </ul>
</div> 

To this:

<div class="block_content">
   <ul class="tree {if $isDhtml}dhtml{/if}">
      {foreach from=$blockCategTree.children item=child name=blockCategTree}
         {if $child.id !=80}
            {if $child.id !=81}
               {if $child.id !=82}
                  {if $smarty.foreach.blockCategTree.last}
                     {include file="$branche_tpl_path" node=$child last='true'}
                  {else}
                     {include file="$branche_tpl_path" node=$child}
                  {/if}
               {/if}
            {/if}
         {/if}
      {/foreach}
   </ul>
</div> 

Shape {if $child.id !=80 || $child.id !=81 || $child.id !=82} didnt work for me, but you can try it ;)

 

This is not total cosher solution, but absolutly works ;)

This solution works perfectly on PS 1.6.1.6

Thank you very much.

Link to comment
Share on other sites

×
×
  • Create New...