0

From time to time I have pages within the Drupal architecture that I don't want to use the standard page.tpl.php.tpl and html.tpl.php. I want to create a template for specific nodes that uses a unique one for each. It cannot have any drupal code in it. Is this possible?

1

This applies to Drupal 7...

page.tpl.php

Make a copy of page.tpl.php from your active theme's directory e.g

/sites/all/themes/your_theme/page.tpl.php

If the theme does not have page.tpl.php file then make a copy of Drupal's default version at

/modules/system/page.tpl.php

Rename your copied file in your theme folder with one of the following naming convention. Use this format for a node content type (example uses a custom content type called 'news'):

page--node--news.tpl.php

Or for a specific node use the ID number (example uses node ID of 12):

page--node--12.tpl.php

html.tpl.php

The same applies for html.tpl.php For a specific content type use:

html--node--news.tpl.php

For a specific node

html--node--12.tpl.php

These will take precedence over the generic html.tpl.php or page.tpl.php if the ID or content type matches.

0

You should use theme_debug if you are dealing with Drupal 7.33 or newer. That will give you all the information you need in the html source code, for the active templates used in your page and - most importantly - for suggested template files that would allow you to override as you see fit.

And yes, you can have a tpl.php file without any php code in it, be it Drupal specific or not.

Good luck!

  • My biggest issue is using a specific html.tpl.php for a specific page. Can this be done? – MacLean Fitzgerald May 31 '16 at 21:01
  • Is coding an option for you? – Stefanos Petrakis May 31 '16 at 21:04
  • for sure. Im not the greatest at creating my own, but I can certainly manipulate it. I activated theme_debug, it works, but Im not 100% sure what I'm doing with it. In the end I needs to create 2-3 nodes that have zero drupal code in it. All the other pages can have the standard Drupal header code(css, js), but there pages need to be blank through and through. If you look at source code, nothing appears. – MacLean Fitzgerald May 31 '16 at 21:12
  • You are talking about the source code of the served html page? You want this to be empty? Pardon the subsequent questions, I have the feeling your requirement is different that the original question. – Stefanos Petrakis May 31 '16 at 21:32
  • no matter. I think your theme_debug did the trick. I didnt quite understadn what it was doing at first. But once I did, i was able to create the correct html header and thus create a blank page. Now i can do this for each node i create that I want outside the normal drupal pages. thank you very much. – MacLean Fitzgerald May 31 '16 at 21:36

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.