开发者

Custom theming Drupal 6 Menus

开发者 https://www.devze.com 2023-03-27 02:37 出处:网络
Is there a hook or preprocess 开发者_如何学JAVAfunction that I can access to write my own theming function for a drupal menu (in this case, primary links)?

Is there a hook or preprocess 开发者_如何学JAVAfunction that I can access to write my own theming function for a drupal menu (in this case, primary links)?

I have a rather complex menu structure that requires a little extra markup than I'm currently getting by just rendering the menu items in a block (involving sub-menus with a little custom markup) and really need to get access to build the menu's content variable myself, ideally from an array that has all the primary links and their children in scope.


While it may not be the best solution, it is one that worked quite quickly and painlessly:

Drupal keeps a cached version of all your menus in the cache_menu table, I ran a this query to retreive a serialized string containing all the contents of the menu:

SELECT data FROM menu_cache WHERE serialized = 1 AND cid LIKE 'links:primary_links:%';

Substitute primary_links for whatever the name of your menu is and call unserialize on $row->data to get a structured array of everything you should need to build a custom menu.

I call a function in hook_preprocess_block that swaps the content of the menu block with my own and everything seems to be working fine.

0

精彩评论

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

关注公众号