sanwa Posted January 15, 2011 Share Posted January 15, 2011 I am customising the homefeatured block to show products. Everything works fine except I also need to display the subcategory of the product instead of the product name. I am using the following code in homefeatured.php: function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); global $link; $smarty->assign(array( 'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true), 'link' => $link )); return $this->display(__FILE__, 'homefeatured.tpl'); } } With the code I am able to retrieve the parent category name. But I need the child category name. Please help! Link to comment Share on other sites More sharing options...
dambie Posted July 10, 2011 Share Posted July 10, 2011 Solved the problem? Link to comment Share on other sites More sharing options...
vivek tripathi Posted July 15, 2011 Share Posted July 15, 2011 To show subcategory name in homefeatured module Replace following line of module->homefeatured->homefeatured.tpl {$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'} with the code {$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'} categorie name-> {$product.category_default} you have to add {$product.category_default} in foreach loop under li Link to comment Share on other sites More sharing options...
dambie Posted July 15, 2011 Share Posted July 15, 2011 And how to add a link to a subcategory?Your code works but only displays the name Link to comment Share on other sites More sharing options...
vivek tripathi Posted July 18, 2011 Share Posted July 18, 2011 Hi Dambiehere is complete code with proper link to subcategorieI found that this editor skip href="{$link-> and display complete code so I have attached code.txt file please find the attachment for complete code and also let me know if You have any idea why editor skips that codeTo show subcategory name in homefeatured module Replace following line of module->homefeatured->homefeatured.tpl {$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'} with the code {$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'} categorie name-> getCategoryLink($product.id_category_default, $category.link_rewrite)}" title="{l s='More about'} {$product.category_default}">[spam-filter]$product.category_default}|escape:'htmlall':'UTF-8'} you have to add {$product.category_default} in foreach loop under li code.txt Link to comment Share on other sites More sharing options...
dambie Posted July 18, 2011 Share Posted July 18, 2011 It works, thanks a lot !! Link to comment Share on other sites More sharing options...
maxkdiv Posted August 30, 2011 Share Posted August 30, 2011 hallo, thx for modification. however it displays the category as ID/number and not as name. how to display the name? thx Link to comment Share on other sites More sharing options...
monstrel Posted January 10, 2012 Share Posted January 10, 2012 Works great, this is what I am looking for. Thanks vivek. Link to comment Share on other sites More sharing options...
CartExpert.net Posted January 11, 2012 Share Posted January 11, 2012 Hello! If your problem is solved, please change the topic title and add '[sOLVED]' to the beginning. Link to comment Share on other sites More sharing options...
sslayer Posted January 11, 2012 Share Posted January 11, 2012 thanks vivek! this works great Link to comment Share on other sites More sharing options...
Daniel - PrestaBR Posted January 31, 2012 Share Posted January 31, 2012 Hi Vivek I'm wondering if you have developed some code to show all categories a product is listed in homefeatured module. Something like: Product's Categories: Handmade, Craft, Art, Bags, Clothes, Exclusive Thanks a lot. Link to comment Share on other sites More sharing options...
junfu Posted April 25, 2012 Share Posted April 25, 2012 Vivek, Thanks for the code , My prestashop version is 1.3.6 , and with the link <a href="{$link->getCategoryLink($product.id_category_default, $category.link_rewrite)}" title="{l s='More about'} {$product.category_default}">[spam-filter]$product.category_default}|escape:'htmlall':'UTF-8'}</a> It doesn't work ,my hooked featured module is blank help would be apprieciated Link to comment Share on other sites More sharing options...
Rodul Posted February 22, 2015 Share Posted February 22, 2015 thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now