0

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

2
  • Did you clear the cache?
    – cayerdis
    Dec 25, 2012 at 21:28
  • yes, thank you, the cache was cleared several times
    – latvian
    Dec 27, 2012 at 14:11

3 Answers 3

1

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.

2
  • 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, 2012 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.
    – LWal
    Jan 8, 2013 at 18:36
0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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