Search code examples
phpdrupaldrupal-7

How to find out which php files where used to render a page in drupal?


I tried using the devel query log which didn't help. Could I do this with a module?

I want to find out which file is used to generate the page to look at the code to possibly modify it / write a module for it.


Solution

  • In template.php you can do this :

    function MYTHEME_preprocess_page(&$vars){
      if(isset($_GET['debug']) && $_GET['debug'] == 1) {
         dsm(menu_get_item(), 'Menu information'); // show all menu routing information
         dsm(debug_backtrace(), 'Backtrace'); // show coding tree execution in order
         dsm($vars, 'data'); // optionnally display datas available 
      }
    }
    

    use it like : http://www.mytestdomain.com/my-page-to-test.html?debug=1

    NB : Clear cache before to use the first time

    doc : template_preprocess_page

    menu_get_item

    debug_backtrace