如何在Drupal主题菜单块? [英] How to theme a menu block in Drupal?
问题描述
我已经根据主菜单创建了三个不同的块。现在我想:
-
为所有三个块创建唯一的HTML,这意味着修改周围的包装器和
< ul>
和< li>
构建菜单。我想设置特殊课程并删除所有添加了Drupal的东西 -
将不同的类附加到每个块中的不同级别。其中一个块将显示菜单的两个级别,即它将显示一个子菜单。我想为子菜单设置一个特殊的课程...
这似乎是不可能的... :(
提前感谢您的帮助!!!!
明星是一个棘手的野兽,根据你需要做的事情往往会有很大的变化,即使有很详细的描述,我仍然可以说依赖,但这里有几个步骤可以帮助你指出正确的方向。
步骤1:使用Caffeine Addict建议的块tpl.php,如果您不确定该命名什么.tpl。 php,我推荐和amp ;在api.drupal.org上 template_preprocess_menu_tree 功能起点如果您使用 devel模块,请使用 dpm($ variables);
在每一个人看到你从一开始就需要处理的事情。
我希望有帮助!当他说 superfish 可能是另一种选择时,我同意咖啡因上瘾者。您还应该查看菜单块模块,将条件子部分分解成自己的块。
This should really be a basic question but I simply don't get it after hours of searching. The question is, how do I theme menu blocks in Drupal 7?
I've created three different blocks all based on the main menu. Now I want to:
create unique HTML for all three blocks, that means modifing the surrounding wrapper and the
<ul>
and<li>
that builds the menu. I wanna set special classes and remove all of the Drupal-added stuffattach different classes to the different levels within each block. One of blocks will show two levels of the menu, i.e. it will display a submenu. I want to set a special class on the for the submenu...
This seems impossible... :(
Thank you in advance for the help!!!!
Theming is a tricky beast that often varies a lot depending what you need to do. Even with your very detailed description I can still say "it depends", but here are a couple steps that may help you get pointed in the right direction.
Step 1: Use a block tpl.php as suggested by Caffeine Addict. If you're not sure what to name the .tpl.php, I recommend the Theme Developer module. It's buggy, but you can use it to select an particular element and have it tell you suggestions for naming of .tpl.php files.
Step 2: Use a theme / preprocess function in template.php to modify the pre-defined variables and markup. Be sure to check on the theme_menu_tree & template_preprocess_menu_tree functions on api.drupal.org for starting points. If you're using the devel module, use dpm($variables);
in each of those to see what you have to work with from the start.
I hope that helps! I agree with Caffeine Addict when he says that superfish might be an alternative. You should also probably check out the menu block module for breaking out conditional sub-sections into their own blocks.
这篇关于如何在Drupal主题菜单块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!