Skip to content

Instantly share code, notes, and snippets.

@mec
Created June 1, 2014 20:26
Show Gist options
  • Save mec/6e0f82f45fc7baa0eedb to your computer and use it in GitHub Desktop.
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()
name = Custom Pages Module
description = Provides routes and pages with custom themes.
core = 7.x
<?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