Generate list of catagories/subcategories


The goal is to replace the current catalog by a list of categories/subcategories. I hooked catalog.tpl and added the following code:


{include file="views/categories/components/categories_tree.tpl" categories=$root_categories}

This generates a list of categories but subcategories are missing, although categories_tree.tpl script suggests they should show up.

Input and a solution would be welcome.


Do you need something like the sitemap presentation of categories-subcategories?

If yes I think then you should start wit looking at those files.

Let me know and when I get the chance (thank you avast for the extra work today) I will have a look.


Hi Fotis,

Thanks for the input. Yes, sitemap does generate what I want. I found very similar scripts all around but I do not know how to initialize them beside $root_categories, which generates only the list of categories at level=0. Knowledge issue on my side. I belive:

{include file=“views/categories/components/categories_tree.tpl” categories=$root_categories}

should work if I knew what to put in place of 'categories=$root_categories'; maybe you have an input on this.

To make it short, I created a category block with appearance set to plain and put it in the home page (what I also wanted); it does the work. Too bad I cannot customize the catalog page through the admin.

I got my AVAST time yesterday! Very nice…


I think your file is views/sitemap/components/categories_tree.tpl


{foreach from=$all_categories_tree item=category key=cat_key name=“categories”}

{if $category.level == “0”}

{if $ul_subcategories == “started”}

{assign var=“ul_subcategories” value=“”}


{if $ul_subcategories != "started"}

    {assign var="ul_subcategories" value="started"}
  • "1"}{math equation="x*y+13" x="7" y=$category.level}px{/if};">{$category.category}

  • {/if}
    {if $smarty.foreach.categories.last}


try to include that and get back to me.

Yes, very similar to views/categories/components/categories_tree.tpl.

The code does not do anything by itself; if I replace $all_categories_tree by $root_categories I get the top categories as a list. Still missing some initialization or calling code. I am not there yet.

Thanks very much anyway.

[color=#282828][font=arial, verdana, tahoma, sans-serif]Philadl,

You should replace line[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]
$root_categories = fn_get_subcategories(0);


$params = array('plain' => true);
list($root_categories, ) = fn_get_categories($params);

in [color=#282828][font=arial, verdana, tahoma, sans-serif]$DIR_ROOT/controllers/customer/categories.php[/font][/color]