Madeline67 Posted June 7, 2012 Share Posted June 7, 2012 (edited) Hello, I search since 3 Days a Solution to my problem... I want to have my sub-sub-categories under my sub-categories, like this Picture : I find code but it don't works, I test and I test... In category.tpl : {foreach from=$subcategories item=child name=children} [url=""] {$child->name|escape:'htmlall':'UTF-8'}[/url] {if $smarty.foreach.children.last}{else},{/if} {/foreach} And in controllers/categerycontroller.php on line 120 /** PrestaTER : ajout de l'affichage des catégories enfants **/ self::$smarty->assign('category', $this->category); foreach ($subCategories AS $subcat) { $child = new Category((int)($subcat['id_category']), (int)self::$cookie->id_lang); $children = $child->getSubCategories((int)self::$cookie->id_lang); $result[] = array('id_category'=> $subcat['id_category'], 'name'=> $subcat['name'] , 'id_image'=> $subcat['id_image'], 'legend'=> $subcat['legend'] , 'children'=> $children); } //if (Db::getInstance()->numRows()) //self::$smarty->assign('subcategories',$this->result); /** PrestaTER : ajout de l'affichage des catégories enfants **/ Please can someone helps me ? :-( I'm verry lost... Sorry for my bad english, I'm french ;-) Regards, Madeline Edited June 7, 2012 by Madeline67 (see edit history) Link to comment Share on other sites More sharing options...
Madeline67 Posted June 12, 2012 Author Share Posted June 12, 2012 Please help me Link to comment Share on other sites More sharing options...
davidcarrey Posted November 6, 2012 Share Posted November 6, 2012 Anyone ? I wanna do the same thing Link to comment Share on other sites More sharing options...
clayton29657 Posted November 6, 2012 Share Posted November 6, 2012 Hello davidcarrey, ok try this in your category tpl file but please make sure to do back-ups as I have not tested the code nor did i make it. I had it made for my site only and what it does is display your sub-categories into the categories page. If you need help i can not provide it so you can try it. I just have not had time to add it to my site yet but i am. I am using 1.4.9 so it should work for this version and not sure of others. Clayton <!-- Subcategories --> <div id="subcategories"> <h3>{l s='Subcategories'}</h3> <ul class="inline_list"> {foreach from=$subcategories item=subcategory} <li> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}"> {if $subcategory.id_image} <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /> {else} <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /> {/if} </a><br /> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> <br class="clear"/> </div> {/if}" Link to comment Share on other sites More sharing options...
davidcarrey Posted November 6, 2012 Share Posted November 6, 2012 Thank you for your answer. Unfortunately it didn't work for me. The code you sent me is the same that the normal one, just to show the sub-categories. What I would like is to show the sub-sub-categories... Link to comment Share on other sites More sharing options...
nicolasroy4 Posted November 6, 2012 Share Posted November 6, 2012 (edited) Obviously you need to use this function, but I don't know how to use it and get the datas returned in the template .tpl public static function getCategoryCustom($id_category, $id_lang) { if ($parentcategory = Category::getCategory($id_category, $id_lang, true)) { $category = new Category($parentcategory['id_category'], $id_lang); if ($subCategories = $category->getSubCategories($id_lang)) { foreach ($subCategories as &$row) { $subcategory = new Category($row['id_category'], $id_lang); if ($subsubCategories = $subcategory->getSubCategories($id_lang)) { //On ajoute une colonne avec les données de cette sous sous catégorie $row['subcategories'] = $subcategory->getChild($category, $id_lang, $objet); } } //On ajoute une colonne avec les données de cette sous catégorie $parentcategory['subcategories'] = $subCategories; } return $parentcategory; } return false; } Edited November 6, 2012 by nicolasroy4 (see edit history) 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