anoop
anoop

Reputation: 1614

how can i change the entire template of the page according to module in drupal6

I have check lots of area in the web about theming in drupal6. All the tutorials in the web saying theme module, which means the theming a small area or theming a samll blobk etc. But in my case i need to change the entire template of a page when i access a module. Is this is possible in drupal6?

Upvotes: 0

Views: 116

Answers (2)

endorama
endorama

Reputation: 536

Got from Drupal Answers ( https://drupal.stackexchange.com/a/18670 ) :

How can I create a custom page with a different template?

You can use a different template for a page by suggesting a new template file that will be used.

This can be done in a theme, by writing its template_preprocess_page(), or in a module by implementing hook_preprocess_page(). In the case you are using it in a module, template_preprocess_page() needs to be renamed mymodule_preprocess_page(), where "mymodule" is the short name of your module.

function mymodule_preprocess_page(&$variables) {
  if (arg(0) == "node" && arg(1) == "1") {
    array_unshift($variables['theme_hook_suggestions'], "page--custom-template");
  }
}

Upvotes: 0

Pupil
Pupil

Reputation: 23958

You can write if conditions in your theme's template.php function. The function is template_preprocess_page(&$variables)

And in this function, write some if conditions.

For example:
if($some_condition) {
  $suggestions[] = 'YOUR_CUSTOM_TEMPLATE';
}
$variables['template_files'] = $suggestions;

And you will have your template "YOUR_CUSTOM_TEMPLATE.tpl.php". Which should be there in theme's templates directory.

Also, you can have a custom template for a content type. e.g. For a content type student, the template will be:

page--student.tpl.php

Upvotes: 2

Related Questions