Jump to content

gennybeans

Recommended Posts

Hi,

 

So I've run into a bit of a jam with the Top Horizontal Menu v1.3.

 

I am using this module to link to CMS pages. But I would love to be able to create parent and child menus.

 

For Example:

 

About Us (parent)

History (child)

Mission(child)

 

Is there any way to do this with this module?

 

And I know a lot of people have suggested Julien's other module, but I have tried it, and it doesn't seem to be working nicely with my breadcrumbs (the breadcrumbs line seems to push above the menu).

 

Any help would be amazing! Thank you.

Link to comment
Share on other sites

  • 3 weeks later...

Hi aany,

 

Thank you for your suggestion. I've read other people suggest it as well, but because I'm using the Matrice theme, the menu doesn't really sit well with the design for some reason.

 

I was hoping for a possible solution for the Top Horizontal Menu v1.3, which is the menu that the theme was made with.

Link to comment
Share on other sites

  • 4 weeks later...

I had the same problem and modified the module to be able to show CMS menu items in submenus according to their CMS category. You will be able to add CMS categories to menu in back office.

 

You need to add the following code to blocktopmenu.php:

 

- after:

// END Manufacturer

- insert:

			// BEGIN CMSCategories
			$this->_html .= '<optgroup label="'.$this->l('CMS Categories').'">';
			$this->getCMSCategoryOption(1, $cookie->id_lang);
			$this->_html .= '</optgroup>';
			// END CMSCategories

 

-after:

	case'CAT':
	  $this->getCategoryOption($id, $cookie->id_lang, false);
	break;

put:

	case'CMC':
	  $this->getCMSCategoryOption($id, $cookie->id_lang, false);
	break;

 

- after:

	case'CAT':
	  $this->getCategory($id, $cookie->id_lang);
	break;

put:

	case'CMC':
	  $this->getCMSCategory($id, $cookie->id_lang);
	break;

 

- and finally at the end append these two functions:

 private function getCMSCategoryOption($id_category, $id_lang, $children = true)
 {
$categorie = new CMSCategory($id_category, $id_lang);
if(is_null($categorie->id))
  return;
if(count(explode('.', $categorie->name)) > 1)
  $name = str_replace('.', '', strstr($categorie->name, '.'));
else
  $name = $categorie->name;
$this->_html .= '<option value="CMC'.$categorie->id.'" style="margin-left:'.(($children) ? round(15+(15*(int)$categorie->level_depth)) : 0).'px;">'.$name.'</option>';
if($children)
{
  $childrens = CMSCategory::getChildren($id_category, $id_lang);
  if(count($childrens))
	foreach($childrens as $children)
	  $this->getCMSCategoryOption($children['id_cms_category'], $id_lang);
}
 }
 private function getCMSCategory($id_category, $id_lang)
 {
global $page_name;
$categorie = new CMSCategory($id_category, $id_lang);
if(is_null($categorie->id))
  return;

//$selected = ($page_name == 'category' && ((int)Tools::getValue('id_category') == $id_category)) ? ' class="sfHoverForce"' : '';
$selected = '';
$this->_menu .= '<li'.$selected.'>';
if(count(explode('.', $categorie->name)) > 1)
  $name = str_replace('.', '', strstr($categorie->name, '.'));
else if($categorie->name!='')
  $name = $categorie->name;
else
  $name = 'Home';

$this->_menu .= '<a href="'.$categorie->getLink().'">'.$name.'</a>';
$childrens = CMSCategory::getChildren($id_category, $id_lang);
$pages = CMSCore::getCMSPages($id_lang,$id_category);
if(count($childrens) || count($pages))
{
  $this->_menu .= '<ul>';
  foreach($childrens as $children)
	$this->getCMSCategory($children['id_cms_category'], $id_lang);
  foreach($pages as $page) {
  $selected = ($page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
  $cms = CMS::getLinks($id_lang, array($page['id_cms']));
		if(count($cms))
$this->_menu .= '<li'.$selected.'><a href="'.$cms[0]['link'].'">'.$cms[0]['meta_title'].'</a></li>'.PHP_EOL;
 }
  $this->_menu .= '</ul>';
}
$this->_menu .= '</li>';
 }

 

I attached modified blocktopmenu.php. I hope you'll find it useful.

 

Best regards,

Przemek

 

 

blocktopmenu.php

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

@sofcik

 

Hey! Thank you so much for posting that! In the back-end, it seems to be working quite nicely. The options are there.

 

But even after saving the menu items I create, nothing changes on the front-end.

Is there anything in the .tpl file that I also need to change in order for changes to take effect?

 

Thanks for your help!

Link to comment
Share on other sites

  • 1 month later...

i didn't find any other way - changed blocktopmenu.php back ...

I've created in CMS module new category and internal pages . And than wrote manually code in blocktopmenu.tpl like <LI><a>category</a></li><ul><li>.....</li></ul> etc. The way it should be(((

So it let me add one more tab to the top menu.. (

Link to comment
Share on other sites

  • 4 weeks later...
  • 5 weeks later...

Hello, I'm not just a noob but NOT a coder either, so I have no idea where to insert this <LI><a>category</a></li><ul><li>.....</li></ul> etc. The way it should be(((" blocktopmenu.tpl has 22 lines and have no idea where to insert this code.

 

<LI><a>category</a></li><ul><li>.....</li></ul> etc. <---does this means I have to add as many as <li> as needed? I have 37 links that I need to show in my dropdown menu, meaning I need to show 37 <li> ?

 

thanks!

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...
  • 1 year later...

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...