If you have something like this:
function YOURMODULE_menu() {
$items=array();
$items['yourmodule/cool/path'] = array(
'page callback' => 'YOURMODULE_cool_path_callback',
// etc
);
// etc
return $items;
}
then Drupal will utilize page-yourmodule-cool-path.tpl.php
(eg, the /
s are turned into -
s) if it exists without any further action besides clearing your caches to pick it up.
In fact, if you create a page-yourmodule.tpl.php
file, Drupal will use it for ANY path starting with yourmodule
, eg, yourmodule/cool/path
, yourmodule/cooler/path,
etc., that doesn't have a more specific template created for it.
See Drupal 6 Template Suggestions for more info.
But, of course, if you have lots of paths that you want to use a single custom page template for that aren't so similarly defined, you can certainly use hook_preprocess_page() to suggest a non-standard template file:
function YOURMODULE_OR_THEME_preprocess_page(&$variables) {
if (/* whatever is true */) {
$variables['template_files'][] = 'page-custom';
}
}
which would then have Drupal using page-custom.tpl.php
for whatever was true in that if
. Just realize if custom
is defined as a path somewhere on your system, or is the start of a path, Drupal will use this template there as well.
Just realize somewhat obviously that whichever route you take, the page templates reside in your theme's directory and not with your module unless you use a registry alter:
function YOURMODULE_theme_registry_alter(&$theme_registry) {
$theme_hook = 'page';
$modulepath = drupal_get_path('module', 'YOURMODULE') . '/tpl/page';
array_unshift($theme_registry[$theme_hook]['theme paths'], $modulepath);
}
which should cause Drupal to look in a tpl/page
directory of your module for them but this brings up all sorts of other issues.