Jump to content

display all parent categories of a cms page


Recommended Posts

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

  • 2 weeks later...

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 by Pedro Pinto (see edit history)
Link to comment
Share on other sites

  • 10 months later...

 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...