When using the topbar with a multi-level menu, the current implementation of _zurb_foundation_render_link() in template.php adds a secondary clickable link for the category when displaying the mobile version of the menu.

// Add repeated link under the dropdown for small-screen.
$small_link['#attributes']['class'][] = 'show-for-small';
$sub_menu = '<li' . drupal_attributes($small_link['#attributes']) . '>' . l($link['#title'], $link['#href'], $link['#localized_options']);

However, Foundation already takes care of this through Javascript with this code (in foundation.topbar.js, line 236ff in 4.3.1 or line 302ff in 4.3.2)

if (self.settings.mobile_show_parent_link && url && url.length > 1) {
  var $titleLi = $('<li class="title back js-generated"><h5><a href="#"></a></h5></li><li><a class="parent-link js-generated" href="' + url + '">' + $link.text() +'</a></li>');
} else {
  var $titleLi = $('<li class="title back js-generated"><h5><a href="#"></a></h5></li>');
}

In my case this results in the link showing one extra time. So if you have this structure

- Home
- Articles
-- Good Articles
-- Bad Articles

When I'm on the mobile version of the menu, I'll have the three stripes button to display the menu. When I click on that, I see
- Home
- Articles >

When I click on Articles I see

- Articles
- Articles
- Good Articles
- Bad Articles

So in other words I get one link generated via Javascript from Foundation and the same link, generated and themed in template.php.

I've just removed the second link, but I'm not sure why it's there. If the user has Javascript turned off, then the whole thing fails, so it doesn't matter. But I wonder if I have some special circumstance that's causing the double display of that link or if this is something that should be fixed in the theme.

Comments

flaw’s picture

I've noticed the same problem, but when I commented out the three lines after
'// Add repeated link under the dropdown for small-screen.'

I get the following error..
Notice: Undefined variable: sub_menu in _zurb_foundation_render_link() (line 244 of /sitename/sites/all/themes/zurb-foundation/template.php).

ergophobe’s picture

Yeah, you need to do a bit more than that. I was just trying to confirm whether there was something I wasn't considering, because I don't recall that happening previously. If it's happening to you too, I'll generate a patch.

ergophobe’s picture

Status: Active » Fixed

Strangely, I'm not getting the js-generated link anymore and had to revert my code, so I'm going to mark this fixed though it is a bit odd.

ladybug_3777’s picture

I think the double link you were seeing is gone because they changed the data options in foundation.topbar.js to be:

mobile_show_parent_link: false,

If you were to set that value back to true you'd see your duplicated link again. I've been fiddling with this issue with the repeated link for a couple of days now and I'm starting to think that the repeated link that is set in template.php shouldn't be there. Instead it should be removed and be allowed to be controlled the right way through the JS settings for topbar.

ladybug_3777’s picture

Please see this link if you are interested in a patch that will remove the repeated link and allow you to control it's appearance via Top Bar JavaScript settings for "mobile_show_parent_link" instead:

https://drupal.org/node/2280617#comment-8849457

ergophobe’s picture

Thanks for looking into that. I'll try to review and test your patch soon.

ladybug_3777’s picture

Thank you ergophobe! I just updated my patch so that the new setting can be controlled through the UI. I had forgotten about that part in my last version of the patch. Be sure to review the latest on comment #5 here:

https://drupal.org/node/2280617#comment-8861633

Status: Fixed » Closed (fixed)

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

ladybug_3777’s picture

Status: Closed (fixed) » Needs review

The system auto closed this issue so I'm making sure it goes back to needing review.

ergophobe’s picture

Sorry.... been feeling guilty about not getting back to this, but have also been on the road traveling and barely able to keep up with my hard deadlines (and not even doing that very well).

ladybug_3777’s picture

Totally understandable ergophobe!

ladybug_3777’s picture

Still looking for the patch for this issue (posted here: https://drupal.org/node/2280617#comment-8861633) to be reviewed/approved. I'm going to mark this issue as a duplicate of the other so there is only 1 to review.

ladybug_3777’s picture

Status: Needs review » Closed (duplicate)