mia654321 Posted September 3, 2014 Share Posted September 3, 2014 I'd like to show under category-count siblings subcategories. I have found one solution but it doesn't work for me. category-count.tpl: <!-- Subcategories --> {if isset($subcategories) } <ul> {foreach from=$subcategories item=subcategory} <li> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> {else if $category->active} <ul> {foreach from=$category_siblings item=siblingcategory} <li> {$siblingcategory.name} </li> {/foreach} </ul> {else} ZLE PODMIENKY {/if} CategoryController: <?php class CategoryController extends CategoryControllerCore { public function displayContent() { // Get the global smarty object. global $smarty; // Get current category's parent. $parent_category = new Category($this->category->id_parent, self::$cookie->id_lang); // Get parent category's subcategories (which is current category's siblings, including it self). $category_siblings = getChildren($parent_category,self::$cookie->id_lang,true); /* Assign your siblings array to smarty. */ $smarty->assign( array( "category_siblings" => $category_siblings ) ); /* This we run the normal displayContent, but pass the siblings array to category.tpl */ parent::displayContent(); } } Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2014 Share Posted September 4, 2014 {if isset($subcategories) } <ul> {foreach from=$subcategories item=subcategory} <li> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> {/if} try to use only thins after modification don't forget to clear shop cache! (it's better to disable it and to turn force compile on while you work on your template) Link to comment Share on other sites More sharing options...
mia654321 Posted September 5, 2014 Author Share Posted September 5, 2014 I don't wanna display only subcategories but also siblings on pages which don't have subcategories. I think that I am using bad way to assign variable to the themes/default/categorie-count.tpl. Link to comment Share on other sites More sharing options...
mia654321 Posted September 9, 2014 Author Share Posted September 9, 2014 I have tried to rename function displayContent() to initContent() and it works! displayContent() doesn't exist in controllers/front/CategoryController.php so i couldn't override this function. Link to comment Share on other sites More sharing options...
stejob Posted November 13, 2014 Share Posted November 13, 2014 (edited) I really would like to do the same thing. But I can't get it to work. Is there anything else that needs to be done to make this work? In controllers/front i already have this CategoryController.php <?php class CategoryController extends CategoryControllerCore { public function initContent() { parent::initContent(); /************************* Images Array ******************************/ if(method_exists('Product','getProductsImgs')) { $image_array=array(); for($i=0;$i<count($this->cat_products);$i++) { if(isset($this->cat_products[$i]['id_product'])) $image_array[$this->cat_products[$i]['id_product']]= Product::getProductsImgs($this->cat_products[$i]['id_product']); } $this->context->smarty->assign('productimg',(isset($image_array) AND $image_array) ? $image_array : NULL); } /************************* /Images Array ******************************/ } } Should I change that some how or should the new CategoryController just be placed in /controllers? Thanks in advance Edited November 13, 2014 by stejob (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