Jump to content

only display sub categories when parent is selected


Recommended Posts

I want to have a horizontal nav with six main categories listed. i.e Women's | Men's | Kid's .... when one selects one of the parent categories only the child sub categories should be displayed in the category block module... i don't want to see unrelated categories from every parent... does this make sense? is this possible?

as an example check http://www.gap.com or http://www.urbanoutfitters.com

1460_MPPsNYRtw6uXBiYU8syL_t

Link to comment
Share on other sites

  • 2 months later...

I forgot to post my solution ... Here it is.

To display only sub categories on the left you'll have to do edit you /module/blockcategories/blockcategories.php file

//construct categories tree
if(isset($_GET['id_category']) || isset($_GET['id_product']))  // only display subcategories
{
  $rootCateg = new Category (intval($_GET['id_category']), intval($params['cookie']->id_lang));
  while($rootCateg->id_parent != 1)  {   
        $rootCateg=new Category($rootCateg->id_parent); 
   }


           $blockCategTree = $rootCateg->recurseLiteCategTree(intval(Configuration::get('BLOCK_CATEG_MAX_DEPTH')));
           $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

           $smarty->assign('currentCategoryId', intval($_GET['id_category']));

           $smarty->assign('blockCategTree', $blockCategTree);
           $smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');
           $smarty->assign('isDhtml', $isDhtml);

           return $this->display(__FILE__, 'blockcategories.tpl');
}
else // don't display category block
  return null;

Link to comment
Share on other sites

  • 1 month later...

Here you are.
So….
> RESTRICTIONS :
1. it is ok for 2 levels but I did go further for a 3rd level… not that much work needed for a 3rf.
2. it doesn’t take into account the current category

> INSTALLATION
1. Unzip the following module in your modules directory
2. In your BO > Modules : Uninstall BlockCategories module
3. Install Categories block with drop down menu
4. Go into BO > Modules > Positions so as to put it whereever you want in your left column.

See ya

================
UPDATE 27 March 2009 : NO RESTRICTIONS ANYMORE.

module available here : http://www.prestashop.com/forums/viewthread/8272/#36984

6404_u52I0TJhMRbAPuiHmR3k_t

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
  • 1 year later...
I forgot to post my solution ... Here it is.

To display only sub categories on the left you'll have to do edit you /module/blockcategories/blockcategories.php file
//construct categories tree
if(isset($_GET['id_category']) || isset($_GET['id_product']))  // only display subcategories
{
  $rootCateg = new Category (intval($_GET['id_category']), intval($params['cookie']->id_lang));
  while($rootCateg->id_parent != 1)  {   
        $rootCateg=new Category($rootCateg->id_parent); 
   }


           $blockCategTree = $rootCateg->recurseLiteCategTree(intval(Configuration::get('BLOCK_CATEG_MAX_DEPTH')));
           $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

           $smarty->assign('currentCategoryId', intval($_GET['id_category']));

           $smarty->assign('blockCategTree', $blockCategTree);
           $smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');
           $smarty->assign('isDhtml', $isDhtml);

           return $this->display(__FILE__, 'blockcategories.tpl');
}
else // don't display category block
  return null;



Where should I paste this code please? into which line please? thank you !
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...