menu_block.api.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Menu Block module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Alter the menu tree and its configuration before the tree is rendered.
  12. *
  13. * @param $tree
  14. * An array containing the unrendered menu tree.
  15. * @param $config
  16. * An array containing the configuration of the tree.
  17. */
  18. function hook_menu_block_tree_alter(&$tree, &$config) {
  19. }
  20. /**
  21. * Return a list of configurations for menu blocks.
  22. *
  23. * Modules that want to have menu block configurations exported to code should
  24. * provide them using this hook.
  25. *
  26. * @see menu_tree_build() for a description of the config array.
  27. */
  28. function hook_menu_block_blocks() {
  29. return array(
  30. // The array key is the block id used by menu block.
  31. 'custom-nav' => array(
  32. // Use the array keys/values described in menu_tree_build().
  33. 'menu_name' => 'primary-links',
  34. 'parent_mlid' => 0,
  35. 'title_link' => FALSE,
  36. 'admin_title' => 'Drop-down navigation',
  37. 'level' => 1,
  38. 'follow' => 0,
  39. 'depth' => 2,
  40. 'expanded' => TRUE,
  41. 'sort' => FALSE,
  42. ),
  43. // To prevent clobbering of the block id, it is recommended to prefix it
  44. // with the module name.
  45. 'custom-active' => array(
  46. 'menu_name' => MENU_TREE__CURRENT_PAGE_MENU,
  47. 'title_link' => TRUE,
  48. 'admin_title' => 'Secondary navigation',
  49. 'level' => 3,
  50. 'depth' => 3,
  51. // Any config options not specified will get the default value.
  52. ),
  53. );
  54. }
  55. /**
  56. * Return a list of menus to use with the menu_block module.
  57. *
  58. * @return
  59. * An array containing the menus' machine names as keys with their menu titles
  60. * as values.
  61. */
  62. function hook_menu_block_get_menus() {
  63. $menus = array();
  64. // For each menu, add the following information:
  65. $menus['menu_name'] = 'menu title';
  66. return $menus;
  67. }
  68. /**
  69. * Return a list of menus to use on menu block's settings form.
  70. *
  71. * Menu block's settings page sorts menus for use with its "the menu selected by
  72. * the page" option.
  73. *
  74. * @return
  75. * An array containing the menus' machine names as keys with their menu titles
  76. * as values. The key may optionally be a regular expression to match several
  77. * menus at a time; see book_menu_block_get_sort_menus() for an example.
  78. */
  79. function hook_menu_block_get_sort_menus() {
  80. $menus = array();
  81. // For each menu, add the following information:
  82. $menus['menu_name'] = 'menu title';
  83. // Optionally, add a regular expression to match several menus at once.
  84. $menus['/^my\-menus\-.+/'] = t('My menus');
  85. return $menus;
  86. }
  87. /**
  88. * @} End of "addtogroup hooks".
  89. */