First of all: thanks for this module, imho it is the best menu around.

However, there is something I find quite annoying: when rolling over a menu item with subentries and the submenus shows up EVERYTHING else below that region (header in my case) moves down.
You can see a couple of examples of this behaviour in pages submited by users: http://www.kralovedvorsko.cz/ and http://www.go-dating.net/
The behaviour I expected is the much more elegant approach in the original example http://www.e-joussour.net/en where everything stays in place.

I assume this must be a CSS trick, but I just have no idea how to implement it.

Any help will be highly appreciated.

Comments

Adam S’s picture

I have some css here that might help. Just put http://thechefsgalley.com/sites/all/themes/openpublish/ before the .png links if you want to look the images. Basically I created a 46px high box and dropped the sub menu 14px. I'm working on it. Would like some way to have the parent to an active submenu to be active too. Let me know what you think. If your using a 960 framework I image it would just slip right in.

/* Navigation */


#navigation-inner { background:transparent url(images/nav-shadow.png) repeat-x left 33px;}

#navigation_menu{padding:9px;margin: 3px 0 10px 0; height:46px; border: 1px solid #15529f;}

#navigation{text-align:center;background:#fff url(images/nav-bg.png) repeat-x left top;}

#navigation ul{margin:0;padding:0; border:none;}

#navigation_menu li{margin:0;padding:0;}

#navigation_menu a{padding:9px 10px;} 

#navigation_menu a:link,#navigation_menu a:visited{ text-decoration:none; font-size:1.25em;color:#fff; font-weight: bold;}

#navigation_menu a:hover, .dynamic-persistent-menu-menu-item .active {color:white;text-decoration:none;background:transparent url(images/nav-hover.png) repeat-x left top;}

#navigation ul.dynamic-persistent-menu-sub-menu{margin-top:14px;text-align:center;}

#navigation .dynamic-persistent-menu-sub-menu a:link,#navigation .dynamic-persistent-menu-sub-menu a:visited{color:#fff; font-size:1.25em; padding:5px 10px;}

#navigation .dynamic-persistent-menu-sub-menu a:hover{color:#fff; background: none 0; font-weight:bold;text-decoration:underline;}

.block-dynamic_persistent_menu {}
castawaybcn’s picture

thanks for your input adam, it definitely is something but sadly enough I cannot make it work on the site I am building.

My knowledge of css is quite limited (I am actually learning on my own as I develop the site), but it seems to me you are not using the menu within a block, am I right?
Also, are you using your navigation menu? I am using a custom one instead, but even when I changed it to the navigation menu it did nothing. The images were not loaded in any case, and I did get no path errors in the reports either. Should I change your strings
#navigation_menu
to
#my-custom-menu_menu
to make it apply to my menu?

UPDATE:
I managed to avoid the annoying vertical movement with the trick shown in http://drupal.org/node/246655 by adding this to my css (still no luck with theming the menu links though):

#block-dynamic_persistent_menu-0
{
  height:3em;
}
Adam S’s picture

Sorry, I forgot that I changed the page.tpl.php file to ad the #navigation selector. Are you using Firefox with the Firebug add on? Here is the code. I went to http://thechefsgalley.com/sites/all/themes/openpublish/images/nav-shadow... and there was a tiny image all the way in the top left. Do you see that it is only a tiny image that is repeated the length of the menu?

<?php /*?>      <div id="nav">
        <?php if (isset($primary_links)) : ?>
          <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
        <?php endif; ?>
        <?php if (isset($secondary_links)) : ?>
          <?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?>
        <?php endif; ?>
      </div> <!-- /#nav --><?php */?> <--! THIS IS THE OLD CODE IN GARLAND THAT I COMMENTED OUT-->
        
        <div id="navigation">    
          <div id="navigation" class="menu  ">
               <div id="navigation-inner">
             <div id="navigation_menu">
       			 	<?php print $navigation_menu; ?>   
	 		 </div> <!-- /navigation_menu--> 
             </div>
             
          </div> <!-- /navigation-->
        </div>
  
castawaybcn’s picture

no worries, I was playing around and got most of it working. What I am struggling with at the moment is changing the looks of:
- main menu links without submenus do not show as active when the page they point to is active
- if a submenu item is visited, its parent is not shown as active

Here's the code I am using. Background images, which do not change, are actually in the header background image:

/* dynamic consistent menu */
#block-dynamic_persistent_menu-0 {
	line-height:25px;
	height:4em;
	text-transform:uppercase;
	margin:10px;
}
.dynamic-persistent-menu-menu {
	height:3em;
	padding: 2em;
}
.dynamic-persistent-menu-menu-item a {
	/*---background-color:#444444;---*/
	padding-left: 6px;
	padding-right: 10px;
	font-size:1em;
	font-weight:600;
	text-decoration:none;
	color:#cccccc;
	margin: 6px;
	border-width:1px;
	border-left-color:#414141;
	border-left-style:solid;
	}
.dynamic-persistent-menu-menu-item a:hover {
	color:#ffffff;
	border-left-color:#404040;
}

.dynamic-persistent-menu-menu-item a.active, .dynamic-persistent-menu-menu-item a.active-trail {
color:#c8d636;
}
.dynamic-persistent-menu-sub-menu {
	height:3em;
	/*---background-color:#777777;---*/
	margin:0;
}

.dynamic-persistent-menu-sub-menu-item a {
	padding-left: 6px;
	padding-right: 10px;
	font-size:1em;
	text-decoration:none;
	color:#717171;
	margin: 5px;
	border-width:1px;
	border-left-color:#cccccc;
	border-left-style:solid;
}

I am attaching a few images showing the current behaviour (my site is not quite visible yet, sorry). You can see the current page title in the middle left hand side of the image, the title of the picture also tries to describe the behaviour.

Any ideas why the items in pictures 03xxx and 04xxx are not highlighted?

Thanks a lot for your help!

PS I am actually using Firebug, but I must admit I am a bit overwhelmed by the sheer amount of information it provides ;)

Adam S’s picture

The active menu item uses the class .active. You can use that to theme your active top menu. I don't think that you can have both the sub menu and the parent menu as active at the same time, which would be cool. Hopefully someone will code the logic to get that done soon. I wish I knew how.

castawaybcn’s picture

Strange. In the example provided for the module you can see the exact behaviour I was writing about. See:
http://www.e-joussour.net/en/category/7/156/171 where both submenu and parent are active, unlike in my 03_xx picture
and
http://www.e-joussour.net/en/category/7/194 where top menu (without submenus) is active, just what I would like to happen in my 04_xx picture). Am I using the .active class wrong here? should it be a:active instead?

It feels better that this is not such a simple issue to deal with, though, I will keep on trying and let you know if I find anything. In the meantime any feedback which may cast some light on the matter is much welcome.

PS
when I manage to get this working I will write a short howto/documentation with a list of the css classes and the items they affect for this fantastic menu.

Adam S’s picture

Your very determined. Thanks for sharing that site. It gives me some ideas. What needs to happen is when the menu is being formed on the server the information is being passed through a theme function. The theme function adds that expanded class to the top menu if one of the children are active. I wonder how to write the logic if a primary menu item is active and it has parent then theme the parent with a class of expanded. I'm looking at those classes on the page..... I think they look familiar. I found them. See the class. If $menu is true then $class = expanded. If $menu is false and $has_children is true then $class = 'collapsed or $menu is false and $has_children is false then $class = 'leaf'. This must be the way that the navigation menu in Garland is formed. Someone might be able to whip up some template.php code to add the class to active menu items so that dpm works.

Sorry about my ramblings.

function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  static $zebra = FALSE;
  $zebra = !$zebra;
  $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  if (!empty($extra_class)) {
    $class .= ' '. $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active-trail';
  }
  if ($zebra) {
    $class .= ' even';
  }
  else {
    $class .= ' odd';
  }
  return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}
castawaybcn’s picture

Your very determined.

Yep, but do let me know if I am getting a bit of a pain... I am perfectly aware that this issue has derived far far away from its original point, which is, btw, already solved. Perhaps I should start a new issue and mark this one as closed. But I am not familiar with the issue tracking system and would rather let the maintainer choose what to do with this.

Thanks for sharing that site

I deserve no credit for this, thank the module's author instead as this is the official demonstration for dpm.

Your ramblings are most welcome, and make a lot of sense to me. If only I had the skills to turn that into php code... I tried yours instead (added it to the end of my theme's template.php), but nothing changed at all.
I also checked the template.php file in garland and could not find any references to the trail class at all.

Thanks a million for your time and patiente, adam. And do let me know if this has already gone too far and you do not wish to waste any morer time on it. No offence will be taken.

Branjawn’s picture

give the block (e.g. block-dynamic_persistent_menu-0) a height.

yrocq’s picture

Branjawn has the right answer. I set this issue as fixed. Don't hesitate to reopen it if it doesn't work.

yrocq’s picture

Assigned: Unassigned » yrocq
Status: Active » Fixed
castawaybcn’s picture

it does, thanks a lot Branjawn!!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.