views:

37

answers:

3

Hello guys

I have to crate a simple CMS using drupal, It has 4 pages and each page has unique design. How can I achieve this?

Thank you

+1  A: 

I take that the four pages you are talking of are nodes. A theme can have different templates for different content types.
In the same way done by template_preprocess_node(), a module can implement hook_preprocess_node(), and suggest a different template file to use.

// This code is present in template_preprocess_node().
// Clean up name so there are no underscores.
$variables['template_files'][] = 'node-'. $node->type;

// This is what the module custom_module.module can write in custom_module_preprocess_node().
$variables['template_files'][] = 'node-'. $node->uid;

If the custom module wants to be sure that the template it is suggesting is checked before other template files, then it can adopt the following code:

if (isset($variables['template_files']) && is_array($variables['template_files'])) {
  $variables['template_files'] = array_unshift($variables['template_files'], 'node-'. $node->uid);
}

The theme must have a template file with the suggested name (node-1.tpl.php for the node with ID 1, in example), or the default template file node.tpl.php will be used.

kiamlaluno
A: 

The Sections module allows you to assign a theme-per-node from the node's edit page.

It's key purpose is to allow a theme per 'section', so for example admin/* could use Garland, mymicrosite/* could use customtheme1 and the rest of the site could use customtheme2, however you can create a 'section-per-node', which is what you are trying to do in section-speak :0)

CitrusTree
I've just re-read this and realised you asked for 'template' and not 'theme'. I'll leave my answer up should it still help, however.
CitrusTree
A: 

If you want a completelly different disign for your pages (not just different background, or the look of the content area or something like this), i think it's better to use page templates instead of node templates. By default you can use templates page-node-nid.tpl.php (substitute nid with the id of your node).

If you want, for example, a different design for a particular node type - you could use theme_preprocess_page function in your template.php:

function yourtheme_preprocess_page(&$vars, $hook){
     $vars['template_files'][] = 'page-'.$vars['node']->type;
}

The answer is somewhat similar to the one above, but the keypoint here is to use page templates instead of node templates (and preprocess_page instead of preprocess_node). Because using a node template allows you to change the output of the content only, while page template allows you to write the full template from scratch starting with the <html> tag.

P.S. And don't forget to clear cache when dealing with themes, just in case.

angryobject