March 27, 2012

Page–[node-type].tpl.php for Drupal 7

Share on Tumblr

Drupal 7

You may have discovered that many places discuss that you can theme your drupal 7 template per node type by simply creating the template file:


However, this is not avaialable in the current release of drupal 7 without adding a pre-processing hook to your template.php theme file.  In order to have this work, you must include something along the lines of:

function themeName_preprocess_page(&$vars, $hook) {
if (isset($vars['node'])) {
// If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
$vars['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $vars['node']->type);

You can then go about customizing your theme pages as desired by creating the before-mentioned tpl.php files.

Need more help with your drupal 7 development?  Feel free to contact our team to set up a consultation.

Error: Unable to create directory wp-content/uploads/2016/02. Is its parent directory writable by the server?

Jeremy Oms

Jeremy is an entrepreneur and leading manager of New Blood, Inc. Excited about all things Internet related, Jeremy spends much of his time project managing custom web applications and directing advanced search engine optimization efforts.

More Posts - Website

Follow Me:
TwitterFacebookGoogle Plus

Share on Tumblr

Related Posts


  1. I just want to ask you about two ideas :

    1- what is the different between node–blog.tpl vs page–[node-type].tpl.php

    2- how can i test if the content type is teaser or full content

    thank you

    Comment by salam — July 31, 2012 @ 3:44 am

  2. Error: Unable to create directory wp-content/uploads/2016/02. Is its parent directory writable by the server?

    1. page-[node-type].tpl.php will modify the display of the page output. See page template. node-blog.tpl will modify the node output. See the node tpl page. From a developer standpoint, you typically modify the page.tpl if you are looking to change the structure of the parts around the content. More the theme of the site. You would modify the node.tpl when you want to change how the nodes themselves are getting rendered. This might be changing the order of node parts are simply organizing them differently within the page structure.

    2. I am not sure about this answer. Maybe you are looking for this area:

    – Administer → Structure → Content types
    – click the “Manage fields” link for the content type
    – in the row for “Body”, click the “edit” link
    – uncheck “Summary input”
    – save the content type


    – Administer → Structure → Content types
    – click the “Manage display” link for your content type
    – drop down “Custom display settings”
    – uncheck “Teaser”
    – save the content type

    Comment by Jeremy Oms — July 31, 2012 @ 8:45 am

  3. Thank you,, you told me what the exact I’m looking for (different between node–blog.tpl and page–[node-type].tpl.php)

    because now, I build my own theme for drupal7 and I’m new to drupal

    and that’s a bit difficult for me .. and maybe it’ll take me along time :)

    Comment by salam — August 17, 2012 @ 9:27 am

  4. I added the function: myZen_preprocess_page(&$vars, $hook) that you proposed to my template.php but nothing happens. Where I’m wrong?

    Comment by Lucks — November 2, 2012 @ 5:45 am

  5. I tried what was suggested but when your replace the string with — it does not work. I removed this and simply let it use the __ instead and worked great. Great article though!

    Comment by Chad Peppers — January 2, 2013 @ 10:26 am

  6. Hello in the beginning that I am creating my first drupal theme and I have the following problem:

    I have my main website and I want it when you give to a main menu item, I leave other content and not how.

    I attached my function of template.php

    fidias_preprocess_page function (& $ vars, $ hook) {

    if (isset ($ vars [‘node’])) {
    $ vars [‘fidias_hook_suggestions’] [] = ‘page__’. str_replace (‘_’, ‘-‘, $ vars [‘node’] -> type);


    I think my problem is that it does not recognize the template.php

    I would appreciate your help

    Comment by Miguel Angel — April 25, 2013 @ 3:26 am

  7. Error: Unable to create directory wp-content/uploads/2016/02. Is its parent directory writable by the server?

    Try flushing your cache within your drupal admin. This is the typical way to get drupal to recognize your new drupal theme files.

    Comment by Jeremy Oms — May 6, 2013 @ 1:36 pm

  8. Hi,

    Got a question and hoping you can help out.
    I got a page, page–projects.tpl.php.
    But when i want to go to it with drupal/projects he doens’t do anything with it. I tryed your code for template.php but doens’t chance anything.

    Appreciate the help :)

    Comment by Tom — May 29, 2013 @ 5:55 am

  9. Hi Jeremy Oms,

    I am new for drupal 7, I want to implement a website in drupal 7 using zen theme,first mainly i want to change my front page appearance want to put a slide show down of that navigation panel to place my own button like HOME PRODUCTS ABOUT US like that and also put some extra stuff in that.

    I changes some front page using CSS, in page.tpl.php i was removed slogan, navigation panel i want to put my own navigation. while clicking navigation button it should open new body.
    Appreciate the help :)

    Comment by D KALYAN KUMAR — August 20, 2013 @ 10:46 pm

  10. HI Jeremy Oms,



    Appreciate the help :)


    Comment by D KALYAN KUMAR — August 21, 2013 @ 8:35 pm

  11. Error: Unable to create directory wp-content/uploads/2016/02. Is its parent directory writable by the server?

    HI D Kalyan Kumar,

    There are a lot of questions here. I’m not sure that this post is the best place to get your answers. Sometimes watching some tutorial videos may help clear up exactly the process you need to do to take care of the tasks you are looking at. Starting with might be a basic place to start. Jream has a bunch of tutorials you can review as well.

    Here is a video going into details about entering a slider. Again, a lot of details to learn. Keep at it. Eventually things will start to come easier.


    Comment by Jeremy Oms — August 22, 2013 @ 7:15 am

  12. HI Jeremy Oms,

    Thanks for u r advice, sorry to say this i have some basic knowledge of drupal 7 i learn it by watching some video tutorials, in that i am using zen theme with in that i want to change my regions mainnly i want to change the login page to header, for that i was made some changes in page.tpl.php and style.css.

    Please can u tell me where i have to change for such type of out put .

    Appreciate the help :)


    Comment by D KALYAN KUMAR — August 29, 2013 @ 2:16 am

RSS feed for comments on this post. TrackBack URL

Leave a comment