I was trying to get a view for a sub-menu item using Responsive Dropdown Menus but I get

<a href="site/<view>"></a>

instead of the content of the view itself.

It seems that some code needs to get changed into Responsive Dropdown Menus as they did in Superfish, https://www.drupal.org/node/1855996.

Since I need that resolved today I will try to patch Responsive Dropdown Menus to make it work.

Wish me good luck ;-)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alauzon created an issue. See original summary.

alauzon’s picture

Here is my diff. I added a theme function like it has been done in https://www.drupal.org/node/1534734#comment-5874710.

Please tell me what you think of my patch. It's my first contribution so I welcome any comments.

alauzon’s picture

Issue summary: View changes
alauzon’s picture

I removed a line that did not need to be there. Here is my new patch.

alauzon’s picture

Renamed it. :-)

alauzon’s picture

Status: Active » Needs review
alauzon’s picture

Issue summary: View changes
mglaman’s picture

So I'm curious as to why we need to do this in this way? It seems like overhead to have to pass this off to a theme function to return the same output, which in turn could call a theme function. That issue from Superfish doesn't link to any code changes as an example.

Does this patch work for you? Looking at menu_views code I see the following

/**
 * Implements theme_superfish_menu_item_link().
 * Overrides default theming function to intercept views.
 */
function menu_views_superfish_menu_item_link(array $variables) {
  // Only intercept if this menu item link is a view.
  if (isset($variables['menu_item']['link']) && $view = _menu_views_replace_menu_item($variables['menu_item']['link'])) {
    $item = _menu_views_get_item($variables['menu_item']['link']);
    return '<div' . drupal_attributes(array('class' => explode(' ', $item['view']['settings']['wrapper_classes']))) . '>' . $view . '</div>';
  }
  // Otherwise, use the default theming function.
  return theme('menu_views_superfish_menu_item_link_default', $variables);
}

Which means it required Superfish to implement its own, so it can override it. So there'd need to be a patch made against menu_views to support this module, then? That module hasn't had a commit since 2013. I'm not sure I want to add this change for just that use case. Unless I can be proven the performance overhead is minimal.

markhalliwell’s picture

Priority: Major » Normal

So I'm curious as to why we need to do this in this way? It seems like overhead to have to pass this off to a theme function to return the same output, which in turn could call a theme function.

Because a module isn't responsible for theming HTML markup (which is what a "link" ultimate is). Simply using the l() function isn't enough. There is no way for a module/theme to intercept this. By placing it in theme hook, it allows other projects to override it when necessary, which is the case in menu_views when a link's href is <view>.

So there'd need to be a patch made against menu_views to support this module, then?

Yep. Just committed the code in #2552755: Integration with Responsive Dropdown Menus.

That module hasn't had a commit since 2013.

Because it's relatively stable code and does just one thing: provide a view as a menu item.

Unless I can be proven the performance overhead is minimal.

Pretty sure the above statement is proof enough. Once it's in, you don't have to worry about it. If it makes you feel any better, add some comments around the code to explain why all this is necessary (see first response).

mglaman’s picture

markcarver, thanks for the reply and info! I'll circle back to this