Drupal 6x - 主要链接 jquery 手风琴菜单
我正在尝试在 jquery 手风琴菜单中转换我的主链接菜单块(链接文本) 。 我已经测试了 Drupal 的 Accordion Menu 模块,但它对我不起作用。
对于我的主要链接块,我或多或少会有这样的 html 输出:
<ul id="accordion">
<li>
<a href="#recent" class="heading">Recent Entries</a>
<ul id="recent">
<li><span class="date">01.19.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.15.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.13.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.11.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.10.2009</span> <a href="#">Recent Entry Title</a></li>
</ul>
</li>
<li>
<a href="#recent" class="heading">Recent Entries</a>
</li>
<li>
<a href="#popular" class="heading">Popular Entries</a>
<ul id="popular">
<li><span class="date">08.16.2008</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">06.12.2008</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">04.12.2008</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">06.12.2007</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">03.12.2007</span> <a href="#">Popular Entry Title</a></li>
</ul>
</li>
<li>
<a href="#categories" class="heading">Categories</a>
<ul id="categories">
<li><a href="#">Category Name</a> <span class="count">7</span></li>
<li><a href="#">Category Name</a> <span class="count">4</span></li>
<li><a href="#">Category Name</a> <span class="count">15</span></li>
<li><a href="#">Category Name</a> <span class="count">29</span></li>
<li><a href="#">Category Name</a> <span class="count">8</span></li>
</ul>
</li>
</ul>
我有一些与子级的主要链接:
- 领土
- 地图
- 图库
- 产品
- 酒
- 眼镜
- 联系人
但我不知道如何继续。我可以仅在“template.php”文件中编辑此函数来达到我的目标吗?
我确信 jQuery 和 jQuery UI 运行良好,因为我已经使用 page.tpl.php 中的上述代码对其进行了测试。
有什么想法吗? 谢谢 再见
编辑
我读了很多文档和drupal论坛,但找不到类似的请求。我可以简单地编辑主链接 html,而无需使用此代码将 id 标签添加到 ul
function basic_menu_tree($tree) {
return '<ul id="accordion" class="menu">'. $tree .'</ul>';
}
问题来自子 ul,事实上,上述函数也在子 ul 上添加 id="accordion" 标签,对 jquery 脚本产生不良
影响只想自定义主链接菜单块 html,我不敢相信没有解决方案... 谢谢
更新
我已经解决了在 template.php 文件中使用上述函数并通过 jquery 脚本添加头类到主链接父级以设置 jquery ui 手风琴头选项(http://jqueryui.com/demos/accordion/#option-header )!
再见
I'm trying to transform my primary link menu block in a jquery accordion menu (link text).
I've tested the Accordion Menu module for Drupal, but it does not function for me.
For my Primary Links Block I would have more or less this html output:
<ul id="accordion">
<li>
<a href="#recent" class="heading">Recent Entries</a>
<ul id="recent">
<li><span class="date">01.19.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.15.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.13.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.11.2009</span> <a href="#">Recent Entry Title</a></li>
<li><span class="date">01.10.2009</span> <a href="#">Recent Entry Title</a></li>
</ul>
</li>
<li>
<a href="#recent" class="heading">Recent Entries</a>
</li>
<li>
<a href="#popular" class="heading">Popular Entries</a>
<ul id="popular">
<li><span class="date">08.16.2008</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">06.12.2008</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">04.12.2008</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">06.12.2007</span> <a href="#">Popular Entry Title</a></li>
<li><span class="date">03.12.2007</span> <a href="#">Popular Entry Title</a></li>
</ul>
</li>
<li>
<a href="#categories" class="heading">Categories</a>
<ul id="categories">
<li><a href="#">Category Name</a> <span class="count">7</span></li>
<li><a href="#">Category Name</a> <span class="count">4</span></li>
<li><a href="#">Category Name</a> <span class="count">15</span></li>
<li><a href="#">Category Name</a> <span class="count">29</span></li>
<li><a href="#">Category Name</a> <span class="count">8</span></li>
</ul>
</li>
</ul>
I have some primary links with child:
- Territory
- Map
- Gallery
- Products
- Wine
- Glasses
- Contacts
Devel Themer Module says that I must override "theme_menu_item" function but I don't know how to proceed. Can I reach my goal only editing this function in the "template.php" file?
I'm sure that jQuery and jQuery UI are working well beacuse I've tested them with the above code in page.tpl.php.
Any ideas?
Thanks
Bye
EDIT
I've read a lot of docs and drupal forums, but I can't find a similar request. I can simply edit only primary links html without child using this code that add id tag to ul
function basic_menu_tree($tree) {
return '<ul id="accordion" class="menu">'. $tree .'</ul>';
}
The problem comes with child ul, in fact the above function add id="accordion" tag also on child ul with bad effect to jquery script
I want to customize only Primary Link menu block html and I can't believe there are no solutions...
Thanks
UPDATE
I've resolved using above function in template.php file and adding a header class through jquery script to primary link parents to setting jquery ui accordion header options (http://jqueryui.com/demos/accordion/#option-header)!
Bye
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
重写主题功能是主题中最基本的事情。
简而言之,如果您创建一个名为
[theme_name]_menu_item
的函数,该函数将用于生成 html,而不是默认的:theme_menu_item
。所以是的,这可以在您的template.php
中完成。请注意,这些更改将影响所有菜单项,而不仅仅是主链接菜单中的菜单项。
长版
Overriding theme functions is the most basic thing done in themes.
Short version is, that if you create a function named
[theme_name]_menu_item
, that function will be used to generate the html instead of the default one:theme_menu_item
. So yes this can be done in yourtemplate.php
.Note, the changes will affect all menu items, not just the ones in your primary link menu.
Long version
将 jquery Accordeon 附加到标准主菜单输出有什么问题?这里有您需要的一切。
What's a problem to append jquery accordeon to standard primary menu output? There's everything you need for.