Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Apress.Pro.Drupal.7.Development.3rd.Edition.Dec.2010.pdf
Скачиваний:
66
Добавлен:
14.03.2016
Размер:
12.64 Mб
Скачать

CHAPTER 4 THE MENU SYSTEM

During the process of building the links for a page, Drupal first builds the tree based on path information received from modules’ menu hook implementations and stored in the menu_router table, and then it overlays that information with the menu information from the database. This behavior is what allows you to use menu.module to change the parent, path, title, and description of the menu tree— you are not really changing the underlying tree; rather, you are creating data that is then overlaid on top of it.

Note The menu item type, such as MENU_CALLBACK or DEFAULT_LOCAL_TASK, is represented in the database by its decimal equivalent.

menu.module also adds a section to the node form to add the current post as a menu item on the fly.

Common Mistakes

You’ve just implemented the menu hook in your module, but your callbacks aren’t firing, your menus aren’t showing up, or things just plain aren’t working. Here are a few common things to check:

Have you set an access callback key to a function that is returning FALSE?

Did you forget to add the line return $items; at the end of your menu hook?

Did you accidentally make the value of access arguments or page arguments a string instead of an array?

Have you cleared your menu cache and rebuilt the menu?

If you’re trying to get menu items to show up as tabs by assigning the type as MENU_LOCAL_TASK, have you assigned a parent item that has a page callback?

If you’re working with local tasks, do you have at least two tabs on a page (this is required for them to appear)?

Summary

After reading this chapter, you should be able to

Map URLs to functions in your module or other modules or .inc files.

Understand how access control works.

Understand how wildcards work in paths.

Create pages with tabs (local tasks) that map to functions.

Modify existing menu items and links programmatically.

For further reading, the comments in menu.inc are worth checking out. Also, see http://api.drupal.org/?q=api/group/menu/7.

88

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]