Drupal 7 中的自定义移动菜单无法访问子链接 [英] Custom Mobile Menu in Drupal 7 can't access child links

查看:29
本文介绍了Drupal 7 中的自定义移动菜单无法访问子链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司接管了网站的维护工作,我正在尝试确定如何正确获取顶级(父)链接和子链接.正在使用的代码是:

My company took over the maintenance of a website and I am trying to determine how to properly get both the top-level (parent) links as well as the child links. The code that was being used is:

 <div id="monav">
<ul>
  <?php
$mobile_menu = menu_navigation_links('menu-mobile-nav');
print theme('links__menu_mobile_nav', array('links' => $mobile_menu));

  ?>
  </ul>

这只会吐出顶层.我一直在挖掘论坛和代码,试图找到获取子链接的正确方法.明智的 Drupal 大师,您能指出我正确的方向吗?

This only spits out the top-level. I have been digging through forums and code trying to find the correct way to get the child links. Can you point me in the right direction oh wise Drupal gurus?

注意:将父链接设置为显示为展开状态"不起作用.

Note: setting the parent link to "Show as expanded" does not work.

推荐答案

更新:

上面的代码吐出了一个错误,所以我这样做了.

The above code was spitting out an error so instead I am doing this.

theme_preprocess_page(&$vars) 函数中的template.php

template.php in the theme_preprocess_page(&$vars) function

//Render main menu 
$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
$vars['main_menu'] =  $main_menu_tree;

然后我在 page.tpl.php 中显示菜单使用

Then I am displaying the menu in page.tpl.php using

  <div id="monav">
  <?php
        print render($main_menu);
    ?>
</div>

为了使这个菜单移动,我添加了以下 jquery

To make this menu mobile I added the following jquery

(function ($) {

$(document).ready(function(){
//Mobile Navigation
$('#nav-toggle').click(function(e) {
  $('#monav').toggle();
});
$('#monav li.expanded > a').attr("href", "#");
 $("#monav li.expanded").click(function() {

  $(this).find('.menu').toggle();

   });
 });

})(jQuery);

请注意,我必须将其隐藏在我的 css 中

Note I had to hide this in my css

#monav ul.menu li.expanded .menu{
display:none;
}

这篇关于Drupal 7 中的自定义移动菜单无法访问子链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆