开发者

Using theme functions in custom module

This is a pretty specific issue which may not have an elegant answer. I want to share a menu across two sites one Drupal and one not. I'm using a custom module to implement hook_menu_link_alter and want to output a themed menu to a file. There's no discussion on this point, we need to just expose an html file for the other site. I know a brute force way to do this by just looping through and just re-creating what the theming function already does, but I thought maybe there was a way to actually use the theming function directly.

Right now I'm trying...

theme('links', theme('navigation-links', 'menu-name'), array('id' => 'menu-id'));

but am receiving no output. I'm also receiving no errors, which is a bummer. (Note: I'm not 100% that the theming function for navigation-links is actually theme('navigation-links'')).

Any ideas?

(Note: I alos posted this开发者_运维技巧 question over at the new Drupal StackExchange site but may remove it as the community isn't there yet)


the theming function for links needs an array of links to theme.

you can use something like:

theme('links', menu_navigation_links('menu-name'));

The function menu_navigation_links() exists in includes/menu.inc and it uses the function menu_tree_page_data() which returns the menu's tree data according to the current page you're viewing.

You can use a similar function called menu_tree_all_data(), but you'll have to do the same manipulations that menu_navigation_links() does on the data it returns. otherwise, you'll still get empty menus.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜