You are here

17 June 2011

This snippet is a code from my module that just makes a simple menu item into my admin menu in Drupal 7. I am using menu_hook function to achieve this.

Source code viewer
  1. // Also I have made a tool for this http://browse-tutorials.com/tools/drupal/create-page.
  2. // Just insert your module name, page name, url and check some checkboxes.
  3.  
  4. /**
  5.  * Implementation of hook_menu()
  6.  */
  7. // Change hook to your module machine name.
  8. function hook_menu() {
  9. $items = array();
  10.  
  11. $items['admin/structure/title'] = array( // url and menu link placement for this page
  12. 'title' => 'Title', // menu item title
  13. 'description' => 'Description', // menu item description
  14. 'page callback' => 'function_name_of_page_function', // function that returns or echos pages content
  15. 'access callback' => TRUE, // no restrictions on access rights
  16. 'type' => MENU_NORMAL_ITEM, // this type creates normal menu item
  17. );
  18.  
  19. return $items;
  20. }
  21.  
  22. function function_name_of_page_function() {
  23. // Use echo to make content appear on empty page.
  24. // Use return to make content appear in content region of your active theme.
  25. }
Programming Language: PHP