Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Generate list of catagories/subcategories Rate Topic   - - - - -

 
  • philadl
  • Newbie
  • Members
  • Join Date: 21-Mar 12
  • 6 posts

Posted 21 March 2012 - 03:36 PM #1

Hi,

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

<h3 class="mainbox-title"><span>Products</span></h3>
{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.

Thank,
Philadl

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1448 posts

Posted 21 March 2012 - 03:42 PM #2

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.
Fotis
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • philadl
  • Newbie
  • Members
  • Join Date: 21-Mar 12
  • 6 posts

Posted 21 March 2012 - 04:20 PM #3

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

Philadl

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1448 posts

Posted 21 March 2012 - 08:22 PM #4

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"}
	</ul>
   {assign var="ul_subcategories" value=""}
	{/if}
  <ul class="sitemap-list">
   <li><a href="{"categories.view?category_id=`$category.category_id`"|fn_url}" class="strong">{$category.category}</a></li>
  </ul>
   {else}
	{if $ul_subcategories != "started"}
	<ul>
   {assign var="ul_subcategories" value="started"}
  {/if}
	 <li style="padding-left: {if $category.level == "1"}13px{elseif $category.level > "1"}{math equation="x*y+13" x="7" y=$category.level}px{/if};"><a href="{"categories.view?category_id=`$category.category_id`"|fn_url}">{$category.category}</a></li>
   {/if}
   {if $smarty.foreach.categories.last}
  </ul>
  {/if}
{/foreach}

try to include that and get back to me.
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • philadl
  • Newbie
  • Members
  • Join Date: 21-Mar 12
  • 6 posts

Posted 21 March 2012 - 10:12 PM #5

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.

 
  • h694616
  • Newbie
  • Trial users
  • Join Date: 24-Apr 12
  • 5 posts

Posted 21 May 2012 - 07:00 AM #6

Philadl,
You should replace line

$root_categories = fn_get_subcategories(0);

to
$params = array('plain' => true);
list($root_categories, ) = fn_get_categories($params);
in $DIR_ROOT/controllers/customer/categories.php