Jump to content

Subcategories in H2 tag


Recommended Posts

I already looked everywhere, and maybe is really obvious, but i could not find anything.
 
I need help with this
Prestashop 1.5.6.2
default Categories Block
 
I changed the categories, to be shown in a H1 tag
but now the subcategories are H1 also.
And i need the subcategories to be H2 or another tag
 
 
I made the change here, in category-tree-branch.tpl
i added the H1 tag
 
<li class="category_{$node.id}{if isset($last) && $last == 'true'} 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'}">
	<h1>{$node.name|escape:'htmlall':'UTF-8'}</h1>
	</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>

But i'm not sure what to change, to make ONLY categories with the H1 tag, and subcategories with none or another tag

 

Thanks in advance!

 

Link to comment
Share on other sites

modules/blockcategories/category-tree-branch.tpl calls itself recursively so that it can build sub-category menus within categories.

 

When the file includes itself, you need to pass a variable to the template so that you can detect that it is displaying a sub-category.

 

Something like this:

 

 

<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'}">
    {if isset($subcat) && $subcat == 'true'}                                  
        <h2>                                                                  
            {$node.name|escape:'html':'UTF-8'}                                
        </h2>                                                                 
        {else}                                                                
        <h1>                                                                  
            {$node.name|escape:'html':'UTF-8'}                                
        </h1>                                                                 
    {/if} 
                                                                    
    </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' subcat='true'}
                {else}                                                        
                    {include file="$branche_tpl_path" node=$child last='false' subcat='true'}
                {/if}                                                         
            {/foreach}                                                        
        </ul>                                                                 
    {/if}                                                                     
</li>

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

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...