How does the page load order occur for Drupal?

I understand that first the modules are run and the data is returned to the view files. But which files are responsible for the view loading inside the theme?

Would it be page.tpl.php?

Also I trying to determine the page load when a 404 error is thrown. Which page.tpl.php loads the page when a 404 error is thrown?

I know that drupal_not_found() function returns the data, but how would I know which view would load that page?

2 Answers 2


With regard to error pages, Drupal has its defaults, but you can create your own just like any other node. Just create a page for the error, then go to yoursitename.com/admin/settings/error-reporting and specify it as the page to display. You can do this for 403 and 404 errors.

The error pages are loaded just like any other. Which theme files are loaded depends highly on the theme. In Drupal 6, page.tpl.php is the top-level template file in the theme, and would be used for error pages just like any other page. However, it is quite possible to have other files that only theme certain portions of the page.

I would highly recommend a slow, methodical reading of Drupal's theming guide for an introduction. This will help you understand how Drupal decides which .tpl.php files (as well as CSS, JS, etc.) to use for a given page request.

Also, note that a lot of the details have changed significantly between Drupal 6 and Drupal 7. If you're doing new development, you'd probably be better off focusing on version 7—but of course if you have older sites to maintain, you'll need to look at the relevant documentation.

  • hi, I am working with an existing site with an existing theme, and I have tried putting markers in both my page.tpl.php and modules/system/page.tpl.php, but neither of them are being called. Is there another page.tpl.php that I should be using?? What would your advice be??
    – macha
    Nov 18, 2011 at 15:12
  • If your theme contains a page.tpl.php it will override the one in modules/system. As a general theming rule, you should only have to modify or create files in sites/all/themes/mythemename. It's difficult to offer further advice without knowing anything about your theme; there are all sorts of things that might alter default behavior. Nothing beats understanding the system, and the theming guide I liked above is as good a place to start.
    – eaj
    Nov 18, 2011 at 15:22

The "Living, Breathing, Drupal: The Biology of the Request" does a good job on explaining how Drupal does a page load.

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.