I noticed that when viewing a child page, parents of that page in the menu (navigation or menu_block module) had a blank href. (the current page is linked correctly, as are other non-parent items.. i think)
in menu.inc i noticed
function twitter_bootstrap_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
// Sanitize title
$element['#title'] = check_plain($element['#title']);
if ($element['#below']) {
// Ad our own wrapper
unset($element['#below']['#theme_wrappers']);
$sub_menu = '<ul>' . drupal_render($element['#below']) . '</ul>';
//$element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
//$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
//$element['#attributes']['class'][] = 'dropdown';
$element['#localized_options']['html'] = TRUE;
//$element['#title'] .= '<b class="caret"></b>';
// auch
$element['#href'] = "";
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
specifically
// auch
$element['#href'] = "";
commenting that out gives normal functionality as far as i can see - is it doing something i'm missing?
Comments
Comment #1
frankbaele commentedi will look in to it
Comment #2
zcrow commentedSame thing here. Glad I found this. Was driving me a bit nuts trying to figure it out. I also commented out that line and it is working fine now.
Comment #3
duncan.moo commentedI switched to another theme to confirm that it was in fact twitter_bootstrap causing the issue, took me ages to find that line, and removing it sorts out the issue.
Comment #4
Michsk commentedThat line should make
$element['#href'] = '#';but then#is converted to%23when rendered.The
twitter_bootstrap_menu_linkfunction takes care of the dropdown's from menus which have children. So the problem is that a blank path wont work and a # doesnt rendere correct. But twitter bootstrap needs the parent<a>to have href='#' for the dropdowns to work.I'm looking in to this for some time now but really can't figure out how to set the # in the href.
Comment #5
Michsk commentedActually i would suggest a js fix for this:
// Menu dropdown's href=#
Drupal.behaviors.twitterBootstrapMenu = {
attach: function (context, settings) {
$('.dropdown-toggle', context).attr('href', '#');
}
};
This way we can drop the #href.
Comment #6
duncan.moo commentedOn my subtheme of twitter_bootstrap I did the following to keep the top level menu items while having the dropdown menu appear on click/touch of the down arrow.
Comment #7
andregriffin commentedUnfortunately the function provided by duncan.moo turns normal menu-trees into dropdowns (sort of).
Comment #8
natted commentedAs far as I can tell, the data-target has not been set correctly.
It is pretty much one line which allows you to remove $element['#href'] = "";
$element['#localized_options']['attributes']['data-target'] = '#';Patch attached.
Comment #9
andregriffin commentedSeems alright to me. Committed to dev
Comment #10
zmove commentedI reopen the issue, cause I encounter some problems with that function too and I wonder what is the interests to change the parent href to #.
For what I tested, letting the parent href don't change any behavior (correct me if I'm wrong). Even if the click on the link open the dropdown and don't put the user to the new page, it doesn't break anything.
On the other side, all modules that add some custom dropdown with their own logic will be broken. For example I'm testing Commerce Kickstart that provide his own dropdown toolbar management and all parent links, that normally drive the user to a specific page are broken.
So, for compatibility issues, it sounds me more logical to always let the href property as it is.
Other solution (more complex) would be to add some settings for the theme where you can check the menu you want to override, and let the others.
Regards,
Alex
Comment #11
natted commentedHi @zmove
I don't see what you are saying at all.
The change we made was to add the data-target="#" (which is required for by bootstrap) to menu links, which as far as I can tell is not used by the Commerce Kickstart in their dropdown menus.
I installed kickstart, changed to twitter bootstrap (latest dev version) and the kickstart dropdown menus still work. You sure you didn't forget to install jquery_update and change to 1.7+?
Maybe for these issues, if it's not related to twitter_bootstrap theme + core drupal functionality, then it's better to just open a new issue.
Comment #12
zmove commentedHello,
Thank you for the answer.
I use the recommended version of twitter boostrap, released before the commit. It's probably why I encounter some old problems.
I made my own sauce to fix the problem temporarly by waiting a future recommended release.
Regards,
Alex
Comment #13
andregriffin commentedComment #14
andregriffin commentedComment #15
natted commented