Created
June 1, 2014 20:26
-
-
Save mec/6e0f82f45fc7baa0eedb to your computer and use it in GitHub Desktop.
In Drupal 7 you want to provide a URL and a theme file in the module that can be overridden in a theme, the big gotcha here is the name convention in hook_theme()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = Custom Pages Module | |
description = Provides routes and pages with custom themes. | |
core = 7.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mr_custom_pages_menu() { | |
$items['page'] = array( | |
'page callback' => 'my_page_view', | |
'access arguments' => array('access content'), | |
); | |
return $items; | |
} | |
function my_page_view() { | |
return theme('custom_page'); | |
} | |
function mr_custom_pages_theme(){ | |
return array( | |
'custom_page' => array( // this is important, the theme layer will look for this name no matter what is defined below | |
// file name will be custom-page.tpl.php | |
'template' => 'custom-page', // no matter what this is the theme layer will want the file above so let's keep them the same. | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment