0

I've created a page.tpl.php for my website. it must only contain some blocks not the the $content. that's why I created a few blocks attached them to their region and embedded their corresponding views using print views_embed_view("VIEW_NAME","DISPLAY"); this page.tpl.php works but it has some problems.

when I create a node, after redirecting to its page it only displays this page.tpl.php while the address bar is node address, I mean page.tpl.php overrides node pages. the same problem persists for page display of views. I set a path for page display of views but by going there it again displays page.tpl.php . what is wrong with it?

2

I mean page.tpl.php overrides node pages

That isn't true, I just think you haven't quite understood how templates work in Drupal. The hierarchy for templates is:

html.tpl.php
  page.tpl.php
    Everything else (including node.tpl.php)

So as you can see, node.tpl.php is inside page.tpl.php, it's not a replacement for it, nor does it override it. But since you're not outputting the main content block in that template file, it stands to reason that the page content will be empty. Unless otherwise specified by perprocessing/template suggestions, page.tpl.php will be used for every single page.

You also need to know that everything (including the main content) is a block, which must be put in a region in page.tpl.php to be displayed. You would typically find the main_content block in the content (or similarly named) region.

To fix your problem, you need to add the main content region back into page.tpl.php.

  • thanks for your useful reply, main_content displays every thing and if I add this in page.tpl.php the result page will not be what the customer want. they only want to have a few blocks of some content types. so what shall I do? – user21616 Jan 21 '14 at 14:05
0

If you override page.tpl.php, your other page will be overriden too. If you want to override specific page, consult Drupal 7 Template (Theme Hook) Suggestions.

In your case, you can:

  • Create page--node.tpl.php for every page node.
  • Or, create page--internal/path.tpl.php for specific page which its path is internal/path.
  • so different content types need different node pages. how do I can create different node page for different content type and how do I can output the fields? – user21616 Jan 21 '14 at 14:18

Your Answer

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