Jump to content

Displaying current tier categories in categories page


Recommended Posts

where it has the subcategories in the categories.php page.. how can i get the categories in the same tier to show up right above the subcategories..

here is the code for the sub categories links at top of the categories.php

   {if isset($subcategories)}
   <!-- Subcategories -->

{l s='Subcategories'}

       {foreach from=$subcategories item=subcategory}

getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
                   {else}

                   {/if}



getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}

       {/foreach}




   {/if}



insted of showing categories under the current category.. i wnat to link the current category along with the others in the same tier as the current.. thanks

Link to comment
Share on other sites

Add this to category.php on line 50 (just before the $subCategories line):

$parentSubCategories = array();
if ($category->id != 1)
{
   $parent = new Category($category->id_parent);
   $parentSubCategories = $parent->getSubCategories(intval($cookie->id_lang));
}
if (sizeof($parentSubCategories) > 0)
   $smarty->assign('parentSubcategories', $parentSubCategories);



then add the following before the code you mentioned above:

{if isset($parentSubcategories)}
<!-- Subcategories -->

{l s='Parent Subcategories'}

   {foreach from=$parentSubcategories item=subcategory}

getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
               {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
               {else}

               {/if}



getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}

   {/foreach}




{/if}



This code should work, but the problem is that it uses two id="subcategories", which is bad. It would be better if you changed both id="subcategories" to class="subcategories", then in global.css, change all #subcategories to .subcategories.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I also cannot get this to work.

I would like to have that when I'm on a subcategorie that all categories around that one where Iḿ in are showed... so the rest that is under that parent.

How to do this ?

Link to comment
Share on other sites

×
×
  • Create New...