Pedro Pinto Posted October 23, 2015 Share Posted October 23, 2015 how can i display all parent categories of a cms page? i got 3 main categories which have 2 or 3 sub categories, which have 3 or 4 pages by sub category i wish to display all the parent subcategories of determinated page. i wish when i'm in page A of tea it shows me the parent subcategory green label and black label am i clear? -Tea --green label ---page A ---page B ---page C --black label ---page A ---page B ---page C -Coffee --green label ---page A ---page B ---page C --black label ---page A ---page B ---page C any idea? thanks Link to comment Share on other sites More sharing options...
Pedro Pinto Posted November 3, 2015 Author Share Posted November 3, 2015 (edited) done. cmscontroller.php override public function initContent() { parent::initContent(); $this->context->smarty->assign('category_parents', CMSCategoryCore::getChildren((int)$this->cms_category->id_parent, $this->context->language->id));} and then on tpl file: {if isset($category_parents) && !empty($category_parents)} <div> <ul> {foreach from=$category_parents item=category_parents} <li><a class="" href="{$link->getCMSCategoryLink($category_parents.id_cms_category, $category_parent.link_rewrite)|escape:'html':'UTF-8'}">{$category_parent.name|escape:'html':'UTF-8'}</a></li> {/foreach} </ul> </div> {/if} Edited November 3, 2015 by Pedro Pinto (see edit history) Link to comment Share on other sites More sharing options...
Ferrrmolina Posted September 28, 2016 Share Posted September 28, 2016 done. cmscontroller.php override public function initContent() { parent::initContent(); $this->context->smarty->assign('category_parents', CMSCategoryCore::getChildren((int)$this->cms_category->id_parent, $this->context->language->id));} and then on tpl file: {if isset($category_parents) && !empty($category_parents)} <div> <ul> {foreach from=$category_parents item=category_parents} <li><a class="" href="{$link->getCMSCategoryLink($category_parents.id_cms_category, $category_parent.link_rewrite)|escape:'html':'UTF-8'}">{$category_parent.name|escape:'html':'UTF-8'}</a></li> {/foreach} </ul> </div> {/if} Thanks, but, i only get the root category :| 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