Jump to content

display subcategories when parent is empty of product


jpryce

Recommended Posts

Hi all

 

Any one know how to modify code to show sub categories of a parent category when that parent has no products in it.

All my products are neatly filed in their respective sub cats. When you click on the main category in tha catgory block on the left though you obviously get a blank page. I want it to show it's sub cats.

 

Thanks

 

James

Link to comment
Share on other sites

sorry, that's not what i meant. i only want the products to show in the sub cats. therefore they can't be in the parent cat. the problem then is that when you navigate to the parent cat you get a blank page. i want it to show the parents sub category images and descriptions that would then click through to the respective product lists.

Link to comment
Share on other sites

This may also depend on the version and theme of your prestashop but start here.

 

Try this look to your category.tpl file located in themes/yourrheme and see if you have this:

 

 

<!-- Subcategories -->

<div id="subcategories" style="display:none">

<h3>{l s='Subcategories'}</h3>

<ul class="inline_list">

{foreach from=$subcategories item=subcategory}

 

If you do change <div id="subcategories" style="display:none"> to <div id="subcategories" >

Link to comment
Share on other sites

  • 4 weeks later...

Nevermind. I found the code for displaying Subcategories in another theme's category.tpl. I added the following and it worked:

 

{if isset($subcategories)}
 <!-- Subcategories -->
 <div id="subcategories">
  <h3>{l s='Subcategories'}</h3>
  <ul class="inline_list">
  {foreach from=$subcategories item=subcategory}
   <li>
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
  {if $subcategory.id_image}
   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {else}
   <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {/if}
 </a><br />
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
   </li>
  {/foreach}
  </ul>
  <br class="clear"/>
 </div>
 {/if}

Link to comment
Share on other sites

  • 3 weeks 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...