Jump to content

How to show only certain categories in Categories Block?


Recommended Posts

I created a copy of the original categories module and I'm trying to display only the child level categories of my Accessories section.

 

I know I need to modify category-tree-branch.tpl in the Categories Block module (BlockCategories), but I just don't know how to do it.

 

For example:

 

Category 1

-sub category a

-sub category b

Category 2

-sub category c

-sub category d

 

 

Based on the above example, I only want to display the following:

 

-sub category c

-sub category d

 

 

Now I found a partial solution:

 

At the top of category-tree-branch.tpl I added the following:

 

 

 

{if $node.id == 13}

 

 

Now this kind of works...the only problem is it doesn't show it's child lines, which is what I really want.

 

Is there a way to do something like....

 

 

{if $node.parent.id == 13}

 

Basically I'm trying to say "display all the categories where the parent is ID 13).

 

Any ideas?

Link to comment
Share on other sites

I dont know if this will work but isn't it possible to change the query that selects the categories?

 

I think it's at line 172 - 182 of modules/blockcategories/blockcategories.php:

 

SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite

FROM `'._DB_PREFIX_.'category` c

LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.$id_lang.')

LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)

WHERE (c.`active` = 1 OR c.`id_category` = 1)

'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'

AND cg.`id_group` IN ('.pSQL($groups).')

GROUP BY id_category

ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))

 

 

I'm not that good with SQL query's may by somebody else could help you out with how to change the query. I dont recommend changing query's do.

 

Kind Regards,

 

T. Barbillion

Edited by i2imedia (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...