Drupal Hook_Menu redirect to a themable tpl page


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. function mymodule_menu() {
  3. $items = array();
  4.  
  5. $items['my-special-page'] = array(
  6. 'title' => 'This is my custom page',
  7. 'page callback' => 'my_special_page',
  8. 'access arguments' => array('access content'),
  9. 'type' => MENU_CALLBACK,
  10. );
  11.  
  12. return $items;
  13. }
  14.  
  15. function my_special_page() {
  16. return theme('my_special_page');
  17. }
  18.  
  19. function mymodule_theme($existing, $type, $theme, $path) {
  20. return array(
  21. 'my_special_page' => array(
  22. 'arguments' => array('options' => NULL),
  23. 'template' => 'page-my-special-page',
  24. ),
  25. );
  26. }
  27.  
  28. //
  29. //replace the whole page
  30.  
  31. function mymodule_theme_registry_alter(&$theme_registry) {
  32. $theme_hook = 'page'; // my hook name
  33. // Get the path to this module
  34. $modulepath = drupal_get_path('module', 'mymodule');
  35. // Add the module path on top in the array of paths
  36. array_unshift($theme_registry[$theme_hook]['theme paths'], $modulepath);
  37. }
  38. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.