I have a View called 'tag-list'. It displays a list of all taxonomy terms that in the Tag list vocabulary.
I have used this module to create a 'tag-list' menu.
I have a menu called Navi which contains two lists. I have attached my 'tag-list' menu so it is a child of a link on the Navi menu.

My menu is output as follows:

<ul class="menu"> <-- This is the Navi Menu 
<li> Link </li>
<li> Link 
      <ul class="menu">
          <li>
               <ul class="menu">
               <li> Views Menu </li>
               </ul>
           </li>
       </ul>
</li>
<ul>

The Menu View seems to be having an unnecessary UL tag.

Surely the output should be like this:

<ul class="menu"> <-- This is the Navi Menu 
<li> Link </li>
<li> Link 
      <ul class="menu">
          <li>Views Menu </li>
       </ul>
</li>
</ul>

How can I fix this?

Comments

Smartforcedev’s picture

Priority: Normal » Major

+1

Would be nice to have this fixed.

markhalliwell’s picture

Component: Code » Documentation
Priority: Major » Normal
Status: Active » Closed (works as designed)

This module is only responsible for outputting the view, not the markup inside the view.

Other modules that control the theming of a menu (be a theme or sub-module like Superfish are also responsible, not this module).

big_smile’s picture

Status: Closed (works as designed) » Active

It's the module that is creating the extra tags. If I delete the wrapper UL tags from Views, this module still inserts its own LI and UL tags.

The LI tags come from line 80 of the module:

      return '<li' . drupal_attributes($variables['element']['#attributes']) . '>' . $view . $sub_menu . "</li>\n";

If I change it to the following the extra LI tags disappear:
return $view . $sub_menu ;

I am not sure where in the module the UL tags come from.

It would be good if the module gave the option of disabling the UL and LI tags.

markhalliwell’s picture

.

Chris Gillis’s picture

Issue summary: View changes

+1

Chris Gillis’s picture

I tried overriding in my theme, but that is not working... It never gets that far. It executes in the module but not in the theme override.

function mytheme_menu_link(array $variables) {
  // Intercept if this menu link is a view.
  if(module_exists('menu_views')){
    $view = _menu_views_replace_menu_item($variables['element']);
    if ($view !== FALSE) {
      if (!empty($view)) {
        ...
        dpm('called by theme');
        return $view . $sub_menu . "\n";
      }
      return '';
    }
  }
}

#3 makes everything work but I don't really want to hack the module... Any ideas?

BTW, The reason I need to get rid of this is to get nice menus module to work... My view is a list of <li>s, so having one at the root of the view means I end up with a structure like <li><li></li><li></li></li> which breaks everything.

Chris Gillis’s picture

Component: Documentation » Code
markhalliwell’s picture

Category: Support request » Feature request
Status: Active » Closed (won't fix)

As stated above, and to expand on my comment in #2.

I am not sure where in the module the UL tags come from.

Any <ul> element will come from the parent/current menu element. This is not detectable or modifiable, in any way, from the link "level" (i.e. menu_views_menu_link, which is a theme_menu_link() override). This simply is not possible.

The LI tags come from line 80 of the module:

This is necessary because it's already in a menu structure (the parent/current menu <ul> element). Simply adding the view (with whatever markup it's spitting out) has the potential for the markup to become semantically and logically incorrect (see the "Permitted contents" section of https://www.w3.org/TR/html-markup/ul.html). This means that how each and every browser interprets the markup may differ if not followed. That is why it is wrapped in an <li> element, which allows any type of child (see the "Permitted contents" of https://www.w3.org/TR/html-markup/li.html#li).

It would be good if the module gave the option of disabling the UL and LI tags.

If someone provided a patch for this, I may entertain the idea of being able to toggle at least the <li> tag. The <ul> tag cannot be toggled, as mentioned above. However, this is also under the assumption that the view itself is configured properly to spit out just <li></li> elements (with no wrapping <ul> element).

---

Regardless, I'm closing and marking as "Closed (won't fix)" since a) the entire output is specifically "by design", b) no one has actually provided a patch and c) this issue is over 3 years old with no real interest/comments to justify time spent on it.

Do not re-open unless you plan to create a patch that provides this feature.