Reputation: 150
I'm looking for an example of how to run a custom page template for a single url in drupal 6, would be nice to have a preprocess function too.
Upvotes: 0
Views: 326
Reputation: 193
I used the following code in a recent Drupal 6 project; it requires entries into the template.php
file which resides in the root of your theme folder. Simply drop the template page you create into the root of your theme folder, and you're off. {:¬)
You may have this function specified in your template.php
file already; in which case, you'd probably have to refactor to add this. Here's the function in full:
function yourThemeName_preprocess_page(&$vars) {
if (isset($vars['node'])) {
$node = $vars['node'];
$vars['template_files'] = array();
switch ($node->nid) {
case '17': /* to override a specific node ID */
$vars['template_files'][] = 'page-my-page-name';
break;
default: /* to override a content type */
switch ($node->type) {
case 'page':
$vars['template_files'][] = 'page-normal-page';
break;
case 'my_own_content_type':
$vars['template_files'][] = 'page-my-own-content-type';
break;
default:
/* take no action */
}
}
}
}
Where I've specified 'page-my-page-name'
, note that Drupal (or rather, PHPTemplate) will add the '.tpl.php'
part automatically.
This enables you to override by node ID first (more specific), and then more generally by content type, e.g. story or page. To add more overrides, just add more cases in the right place.
Hope this helps.
Upvotes: 2
Reputation: 18923
Humm, you might have to use the Module Panels3 and create a landing page. You can override every element of that page (even outside content area)
Upvotes: 0