Revision: 37747
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 16, 2010 19:21 by resting
Initial Code
//Drupal 5
<?php
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'page':
// Add page template suggestions based on the aliased path.
// For instance, if the current page has an alias of about/history/early,
// we'll have templates of:
// page-about-history-early.tpl.php
// page-about-history.tpl.php
// page-about.tpl.php
// Whichever is found first is the one that will be used.
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ( $alias != $_GET['q'] && $alias == $_REQUEST['q'] ) {
$suggestions = array();
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$suggestions[] = $template_filename;
}
}
$vars['template_files'] = $suggestions;
}
break;
}
return $vars;
}
?>
//Drupal 6
<?php
function phptemplate_preprocess_page(&$vars) {
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias != $_GET['q']) {
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$vars['template_files'][] = $template_filename;
}
}
}
}
?>
Initial URL
http://drupal.org/node/139766
Initial Description
Initial Title
Drupal Page template file based on url
Initial Tags
url, template, page, drupal
Initial Language
PHP