How can i split the page.tpl.php into multiple pages?

2013 年 5 月 8 日4,1840

Posted by mahyarss on May 7, 2013 at 3:44pm

Hi,

I need to split parts of my template because i have a lot of different pages:

page--front.tpl.php

page--news.tpl.php

page--catalog.tpl.php

page--products.tpl.php

page--articles.tpl.php

page--contact.tpl.php

...

Default for other pages: page.tpl.php (basic page like about us).

They are have a same header and footer.

I created page-header.tpl.php & page-footer.tpl.php and put all codes in them.

I used

in top of my page tpl files and works fine.

Is there any way to add includes header and footer files in one place not all page tpl files?

Please help me

thanks

Comments

Posted by nevets on May 7, 2013 at 3:57pm

What makes the pages different. Remember, the Drupal site is dynamic, the content (the main part of page.tpl.php) comes from the database and you do not need (or want in my opinion) a page specific version of page.tpl.php (which what seems like you are after).

Login or register to post comments

Posted by cfox612 on May 7, 2013 at 5:31pm

Normally the header is called in through the html.tpl.php file, and as far as I'm aware, you only have one of those. Here's a great visual representation of the various template files within drupal. It's "best" to try and control your pages within Drupal (meaning the addition of a module like Display Suite or Panels), but multiple template files should be used to control content in the main sections of the page (between the header/footer). Calling in additional header files outside html.tpl.php (I'm guessing) could lead to many issues.

Should also add your naming structure might not be entirely correct either. See for a naming guide for page.tpl.php files. I think you want a node--[content_type].tpl.php.

Login or register to post comments

0 0