Jump to content

Top Menu CMS Category Name Output Code


TDarko

Recommended Posts

Hi i managed to create a output code for the categories in the catalog, 

 

$this->_menu .= '<h5 class="submenu-title">'.$category['name'].'</h5>';
 
 
Im trying to do the same with the CMS categories, but im just getting blanks, and ive tried many different iterations by now.
 
How can you output easily the name of the main CMS category in the menu bar?
 
 
private function getCMSMenuItems($parent, $depth = 1, $id_lang = false)
{
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
 
if ($depth > 3)
return;
 
$categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang);
$pages = $this->getCMSPages((int)$parent);
 
if (count($categories) || count($pages))
{
$this->_menu .= '<ul>';
 
 
$this->_menu .= '<h5 class="submenu-title">CMS CATEGORY NAME HERE</h5>';
 
$this->_menu .= '<ol class="submenu-nav">';
 
 
foreach ($categories as $category)
{
$cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang);
$this->_menu .= '<li>';
$this->_menu .= '<a href="'.Tools::HtmlEntitiesUTF8($cat->getLink()).'">'.$category['name'].'</a>';
$this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1);
$this->_menu .= '</li>';
}
 
foreach ($pages as $page)
{
$cms = new CMS($page['id_cms'], (int)$id_lang);
$links = $cms->getLinks((int)$id_lang, array((int)$cms->id));
 
$selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : '';
$this->_menu .= '<li '.$selected.'>';
$this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>';
$this->_menu .= '</li>';
}
$this->_menu .= '</ol>';
$this->_menu .= '</ul>';
}
}
Edited by TDarko (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...