如何找出哪些 php 文件用于在 drupal 中呈现页面?
How to find out which php files where used to render a page in drupal?
我尝试使用 devel 查询日志,但没有帮助。我可以用模块来做吗?
我想找出用于生成页面的文件以查看代码以可能对其进行修改/为其编写模块。
使用 debug_backtrace() 可能会对您有所帮助。
所以如果要查看"generate the page"进程,可以放在具体的page.tpl.php
var_dump(debug_backtrace());
此模块还可以帮助检查页面 tpl 使用。
https://www.drupal.org/project/devel_themer
在 template.php
中,您可以这样做:
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
}
}
像这样使用它:http://www.mytestdomain.com/my-page-to-test.html?debug=1
注意:第一次使用前清除缓存
我尝试使用 devel 查询日志,但没有帮助。我可以用模块来做吗?
我想找出用于生成页面的文件以查看代码以可能对其进行修改/为其编写模块。
使用 debug_backtrace() 可能会对您有所帮助。 所以如果要查看"generate the page"进程,可以放在具体的page.tpl.php
var_dump(debug_backtrace());
此模块还可以帮助检查页面 tpl 使用。
https://www.drupal.org/project/devel_themer
在 template.php
中,您可以这样做:
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
}
}
像这样使用它:http://www.mytestdomain.com/my-page-to-test.html?debug=1
注意:第一次使用前清除缓存