7

I deleted page.tpl.php file from my current theme, and noticed that all content is still rendering in my Drupal site with a little difference in structure. What is the real use of this file? Can we have any alternative or a replacement for this file?

4 Answers 4

9

page.tpl.php file is used to render your page body content (i.e. content inside <body> tag). Below is one line description of file on api.drupal.org.

Default theme implementation to display a single Drupal page.

If Drupal is not able to find page.tpl.php file inside your theme, then it will use one of the following file:

  1. If your theme has Parent theme, then Parent theme page.tpl.php file.
  2. If no, file provided by system module.

If you're using version control system like GIT, Bitbucket, etc. you can revert your file from last commit. If not you will need to create new file and do necessary changes

2
  • What if I'm using Bartik - default theme in Drupal 7 and there I delete page.tpl.php? Will it affect any functionality on Drupal pages? or will break any functionality? Or will it just affect on look and feel of Drupal site pages? Commented Oct 3, 2016 at 11:40
  • AFAIK it will affect on look and feel as rendering will be done based on tpl file inside system module. To restore page.tpl.php file in bartik theme you can download fresh Drupal setup and copy from it.
    – Yogesh
    Commented Oct 3, 2016 at 11:48
2

All tpl are in /modules/system.

So if your theme miss one template, drupal take one of them inside this directory.

1

There are two things here

  1. If you have a custom theme Drupal will take page.tpl.php file layout
  2. Else it will render default drupal page.tpl.php layout.

It matters when you have a separate page.tpl.php file, Drupal will consider this layout.

1

The content would still be rendered because it uses the default template from Drupal core.

If you include (page.tpl.php) in your current theme folder, it would override the default (page.tpl.php) template.

Some useful links:

https://www.ostraining.com/blog/drupal/drupal-overrides

https://www.drupal.org/node/171194

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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