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

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

问题描述

我的公司接管了一个网站的维护,我正在努力确定如何正确地获得顶级(父级)链接以及子链接。正在使用的代码是:

 < 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大师?



注意:将父链接设置为显示为展开不起作用。

解决方案

更新:



上面的代码是吐出一个错误, 。



template_php在theme_preprocess_page(& $ vars)函数

  //渲染主菜单
$ main_menu_tree = menu_tree(variable_get('menu_main_links_source','main-menu'));
$ vars ['main_menu'] = $ main_menu_tree;

然后我使用


在page.tpl.php中显示菜单

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

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


$ b $ ($($){

$(document).ready(function(){
// Mobile Navigation
$('#nav-toggle')。click(function(e){
$('#monav')。toggle();
});
$('#monav li ()($($)
$(#monav li.expanded)。click(function(){

$这个).find('。menu')。toggle();

});
});

})(jQuery);

注意我不得不将其隐藏在我的css中

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


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>

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.

解决方案

Update:

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

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;

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

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

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);

Note I had to hide this in my css

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

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

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