Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am using one shared template - page.tpl.php for basic pages such as about us, contact us,etc. However, there are rental properties that share a different template, so i have created Content type - property page, and i would like to share a separate template for all pages of content type - property page. How to do it?

I tried to add path 'rentals/property1-3' and use page--rentals.tpl.php but it doesn't work

Any help appreciated.

Thanks

share|improve this question
    
Did you clear the cache? –  cayerdis Dec 25 '12 at 21:28
    
yes, thank you, the cache was cleared several times –  latvian Dec 27 '12 at 14:11
add comment

3 Answers 3

up vote 1 down vote accepted

You need to use this format for drupal to recognize the template for that content type.

page--machine_name.tpl.php

The machine name should be displayed on your YOUR_SITE_NAME.com/admin/structure/types page.

share|improve this answer
    
thank you, this is one of the things i also tried and tried it again after your replay, however it still renders the page.tpl.php first and than it includes the page--machine_name.tpl.php(in our case page--property_page.tpl.php) as render($page['content'])...i would like page.tpl.php for general pages and page--property_page.tpl.php for pages with content type - property_page –  latvian Dec 27 '12 at 15:18
    
have you tried flushing all of the caches? Another option is to create a node template which would be similar node--property_page.tpl.php if you need to manipulate the display on the node level. –  Phos4us Jan 8 '13 at 18:36
add comment

For Drupal 6 :

If you want template file of each node use page-node-[nid].tpl.php.

If you want template file of content type use page-content_type_name.tpl.php

share|improve this answer
add comment

I found the solution from the following Drupal article: http://drupal.org/node/1430110

In short, by adding the following preprocessor at [..]all/themes/themeName/template.php

<?php
function minnehaha_preprocess_page(&$vars, $hook) {
    if (isset($vars['node'])) {
        $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
    }
}

Now, it overrides any content type with following pattern 'page--machine_name.tpl.php' where machine name is the content type name

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.