Jump to content

Can block categories show complete tree including products?


Recommended Posts

Does anyone know if its possible to make the block categories module like this:-

-2008 (Main Category)
 Accessories (Sub category) 
    Product 1 (product)
    Product 2 (product)
 iPods  (Sub category)
    Product 3
 Laptops (Sub category
    Product 4


Ie. make it list the products inside the category?

Thanks,
Kenny.

Link to comment
Share on other sites

This topic needs to really be moved to either the general category of this forum or feature requests :-)

Currently to do what you are asking, you would need some serious modification to blockcategory
I have to say I can't really understand your reason for doing this. Would it be possible to post a link to another site with the same functionality %-P

Also how many products are there going to be on this site ie. if there are more than 10 in each category maybe this will not be the correct solution.
I will look into this further when you can show me another site using this method of navigation ;-)

Link to comment
Share on other sites

Well, it'd be good for a sitemap at least methinks.
Im not sure i've seen it elsewhere. Theres only going to be a few products per sub category, and probably no more than 10 for the whole main category.

I'm looking around and might to turn this a loop, listing products of a category. Would that work?

$nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true);


Hmm..

Link to comment
Share on other sites

I am looking into this for you.
So far if you just replace the code for this function "hookLeftColumn"

Now I just have to work out a way to show this within the category tree

   function hookLeftColumn($params)
   {

       global $smarty;        

       /*  ONLY FOR THEME OLDER THAN v1.0 */
       global $link;
       $smarty->assign(array(
           'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),
           'link' => $link
       ));
       /* ELSE */

       //construct categories tree
       $rootCateg = Category::getRootCategory();
       $blockCategTree = $rootCateg->recurseLiteCategTree(intval(Configuration::get('BLOCK_CATEG_MAX_DEPTH')));
       $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

           $products = $rootCateg->getProducts();
           foreach ($products as $key => $product)
           {
               $products[$key]['name'] = str_replace('"', '\'', $product['name']);
               $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
           }    

       if (isset($_GET['id_category']))
           $smarty->assign('currentCategoryId', intval($_GET['id_category']));
       $smarty->assign('products', $products);    
       $smarty->assign('blockCategTree', $blockCategTree);
       $smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');
       $smarty->assign('isDhtml', $isDhtml);
       /* /ONLY FOR THEME OLDER THAN v1.0 */

       return $this->display(__FILE__, 'blockcategories.tpl');
   }

Link to comment
Share on other sites

  • 2 weeks later...

instead you could make the categories appear in the order you would like:

01.Ztest
02.Htest
03.Atestcategory

just prefix your category names with 01. etc.. might be a pain if you've already added loads of categories but any future ones will be easy

Link to comment
Share on other sites

Simple solution for this just change the ORDER BY clause found in classes/Category.php
for example change lines 443 - 450 to:

       $result = Db::getInstance()->ExecuteS('
       SELECT c.`id_category`, c.`date_add` , cl.`name`, cl.`link_rewrite`
       FROM `'._DB_PREFIX_.'category` c
       LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
       WHERE `id_lang` = '.intval($id_lang).'
       AND c.`id_parent` = '.intval($id_parent).'
       '.($active ? 'AND `active` = 1' : '').'
       ORDER BY c.`date_add` DESC');

Link to comment
Share on other sites

I am looking into this for you.
So far if you just replace the code for this function "hookLeftColumn"

Now I just have to work out a way to show this within the category tree

   function hookLeftColumn($params)
   {

       global $smarty;        

       /*  ONLY FOR THEME OLDER THAN v1.0 */
       global $link;
       $smarty->assign(array(
           'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),
           'link' => $link
       ));
       /* ELSE */

       //construct categories tree
       $rootCateg = Category::getRootCategory();
       $blockCategTree = $rootCateg->recurseLiteCategTree(intval(Configuration::get('BLOCK_CATEG_MAX_DEPTH')));
       $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

           $products = $rootCateg->getProducts();
           foreach ($products as $key => $product)
           {
               $products[$key]['name'] = str_replace('"', '\'', $product['name']);
               $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
           }    

       if (isset($_GET['id_category']))
           $smarty->assign('currentCategoryId', intval($_GET['id_category']));
       $smarty->assign('products', $products);    
       $smarty->assign('blockCategTree', $blockCategTree);
       $smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');
       $smarty->assign('isDhtml', $isDhtml);
       /* /ONLY FOR THEME OLDER THAN v1.0 */

       return $this->display(__FILE__, 'blockcategories.tpl');
   }



Can you show me what file to edit?
Link to comment
Share on other sites

  • 8 months later...
×
×
  • Create New...