/{alias} can be themed with page--{alias}.tpl.php * * Examples: * www.mysite.org/tos can be themed with * page--tos.tpl.php * * www.mysite.org/tos/sub1 can be themed with * page--tos__sub1.tpl.php page--tos.tpl.php * * www.mysite.org/tos/sub1/sub2 can be themed with * page--tos_sub1__sub2.tpl.php * page--tos__sub1.tpl.php * page--tos.tpl.php */ function alias_suggestion_preprocess_page(&$vars, $hook) { // only do this for page-type nodes and only if Path module exists if (module_exists('path') && isset($vars['node']) && $vars['node']->type == 'page') { // look up the alias from the url_alias table $source = 'node/' .$vars['node']->nid; $alias = db_query("SELECT alias FROM {url_alias} WHERE source = '$source'")->fetchField(); if ($alias != '') { // build a suggestion for every possibility $parts = explode('/', $alias); $suggestion = ''; watchdog('debug', 'alias suggestions:
'. print_r($parts, TRUE) .'
'); foreach ($parts as $part) { if ($suggestion == '') { // first suggestion gets prefaced with 'page--' $suggestion .= "page--$part"; } else { // subsequent suggestions get appended $suggestion .= "__$part"; } // add the suggestion to the array $vars['theme_hook_suggestions'][] = $suggestion; } } } watchdog('debug', '$vars[theme_hook_suggestions]:
'. print_r($vars['theme_hook_suggestions'], TRUE) .'
'); } Vinska klet | Protner

Vinska klet