You are here

README.txt in Menu Node API 7

Same filename and directory in other branches
  1. 6 README.txt
Menu Node API
Manages relationships between node ids and menu links.

CONTENTS
--------

1. Introduction
2. Installation
3. Use Cases
4. Developer Notes
5. API Hooks
6. The {menu_node} Table

----
1. Introduction

The Menu Node API project fills in one of the "missing tables" in Drupal 6.
This module does nothing on its own. Instead, it creates and maintains
a {menu_node} table. This table maps the relationship between a node
and its menu link (if any).

The module requires the optional core Menu module to be enabled.

By itself, this module has no functionality. When nodes are assigned to a
site menu, records are created to capture that relationship. If the node or
menu link is deleted, the record is likewise deleted.

The module does fire a set of internal hooks when node-based menus are
created, edited, or deleted.  See section 4 for details.

For Drupal 7, you might also investigate the following modules, which provide
similar functionality:

  http://drupal.org/project/entity_index
  http://drupal.org/project/menu_link

----
2. Installation

To install the module, simply place the folder in your modules directory
(typically 'sites/all/modules'.

Then go to the Module administration page and activate the module. It
can be found listed under the 'Other' category.

----
3. Use Cases

The two most obvious uses for this module are:

-- To build an access control module that leverages the menu hierarchy.
-- To integrate menu hierarchies into the Views module.

The purpose, in both cases, is to allow developers and site builders to use
the menu system as the sole metaphor for a site's structure. For many
small to mid-size Drupal sites, this approach pffers advantages over being
forced to use a taxonomy-based (or other) solution).

----
4. Developer Notes

Aside from the core CRUD functions, this module is of limited use. There
are a few handy functions included, such as menu_node_tree(), but they
may not be suitable for all uses. Feel free to develop your own functions
and tricks.

----
5. API Hooks

At the core of the module are three simple CRUD hooks. They each pass
the same arguments:

  -- hook_menu_node_insert($link, $node)
  -- hook_menu_node_update($link, $node)
  -- hook_menu_node_delete($link, $node)

These functions pass the arguments:

  -- $link
  The menu link being acted upon. (Taken from the {menu_links} table as an
  object).
  -- $node
  The complete node object being acted upon.

NOTE: Using menu_get_item() here returns a router item, not the data
found in {menu_links}. So instead, we load the $item from the {menu_links}
table directly.

NOTE: Nodes can be assigned to multiple menu links. In these cases, the
hook should fire once for each menu link.

There are additional functions that you may find useful. Check the inline
Doxygen comments for details.

----
6. The {menu_node} Table

The {menu_node} table is deliberately simple. It contains a primary key
and two columns:

  -- nid
  Integer, unsigned.
  Foreign key to the {node} table.
  
  -- mlid
  Primary key. Integer, unsigned.
  Foreigh key to the {menu_links} table.

File

README.txt
View source
  1. Menu Node API
  2. Manages relationships between node ids and menu links.
  3. CONTENTS
  4. --------
  5. 1. Introduction
  6. 2. Installation
  7. 3. Use Cases
  8. 4. Developer Notes
  9. 5. API Hooks
  10. 6. The {menu_node} Table
  11. ----
  12. 1. Introduction
  13. The Menu Node API project fills in one of the "missing tables" in Drupal 6.
  14. This module does nothing on its own. Instead, it creates and maintains
  15. a {menu_node} table. This table maps the relationship between a node
  16. and its menu link (if any).
  17. The module requires the optional core Menu module to be enabled.
  18. By itself, this module has no functionality. When nodes are assigned to a
  19. site menu, records are created to capture that relationship. If the node or
  20. menu link is deleted, the record is likewise deleted.
  21. The module does fire a set of internal hooks when node-based menus are
  22. created, edited, or deleted. See section 4 for details.
  23. For Drupal 7, you might also investigate the following modules, which provide
  24. similar functionality:
  25. http://drupal.org/project/entity_index
  26. http://drupal.org/project/menu_link
  27. ----
  28. 2. Installation
  29. To install the module, simply place the folder in your modules directory
  30. (typically 'sites/all/modules'.
  31. Then go to the Module administration page and activate the module. It
  32. can be found listed under the 'Other' category.
  33. ----
  34. 3. Use Cases
  35. The two most obvious uses for this module are:
  36. -- To build an access control module that leverages the menu hierarchy.
  37. -- To integrate menu hierarchies into the Views module.
  38. The purpose, in both cases, is to allow developers and site builders to use
  39. the menu system as the sole metaphor for a site's structure. For many
  40. small to mid-size Drupal sites, this approach pffers advantages over being
  41. forced to use a taxonomy-based (or other) solution).
  42. ----
  43. 4. Developer Notes
  44. Aside from the core CRUD functions, this module is of limited use. There
  45. are a few handy functions included, such as menu_node_tree(), but they
  46. may not be suitable for all uses. Feel free to develop your own functions
  47. and tricks.
  48. ----
  49. 5. API Hooks
  50. At the core of the module are three simple CRUD hooks. They each pass
  51. the same arguments:
  52. -- hook_menu_node_insert($link, $node)
  53. -- hook_menu_node_update($link, $node)
  54. -- hook_menu_node_delete($link, $node)
  55. These functions pass the arguments:
  56. -- $link
  57. The menu link being acted upon. (Taken from the {menu_links} table as an
  58. object).
  59. -- $node
  60. The complete node object being acted upon.
  61. NOTE: Using menu_get_item() here returns a router item, not the data
  62. found in {menu_links}. So instead, we load the $item from the {menu_links}
  63. table directly.
  64. NOTE: Nodes can be assigned to multiple menu links. In these cases, the
  65. hook should fire once for each menu link.
  66. There are additional functions that you may find useful. Check the inline
  67. Doxygen comments for details.
  68. ----
  69. 6. The {menu_node} Table
  70. The {menu_node} table is deliberately simple. It contains a primary key
  71. and two columns:
  72. -- nid
  73. Integer, unsigned.
  74. Foreign key to the {node} table.
  75. -- mlid
  76. Primary key. Integer, unsigned.
  77. Foreigh key to the {menu_links} table.