谢谢@幽灵和@流云,受到启发,过来总结一下。
首先,根据@幽灵的说法,我到theme.inc里面查看了三个函数:
template_preprocess_html 、template_preprocess_page和template_process_html,preprocess_page里面有如下代码,获取了region变量:
foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {
if (!isset($variables['page'][$region_key])) {
$variables['page'][$region_key] = array();
}
}
所以,在page.tpl.php里面有的region产生的变量,该变量在$page数组里面,@流云说得很正确!
之后查了一下文档,Drupal7 默认有两个“隐藏”region,page_top和page_bottom,这两个region是不在block页面显示的,具体看下面的函数:
/**
* Implements hook_system_info_alter().
*/
function system_system_info_alter(&$info, $file, $type) {
// Remove page-top and page-bottom from the blocks UI since they are reserved for
// modules to populate from outside the blocks system.
if ($type == 'theme') {
$info['regions_hidden'][] = 'page_top';
$info['regions_hidden'][] = 'page_bottom';
}
}
这两个变量如何输出,请看下面的函数:
function template_process_html(&$variables) {
// Render page_top and page_bottom into top level variables.
$variables['page_top'] = drupal_render($variables['page']['page_top']);
$variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
// Place the rendered HTML for the page body into a top level variable.
$variables['page'] = $variables['page']['#children'];
$variables['page_bottom'] .= drupal_get_js('footer');
$variables['head'] = drupal_get_html_head();
$variables['css'] = drupal_add_css();
$variables['styles'] = drupal_get_css();
$variables['scripts'] = drupal_get_js();
}
看了这些,疑问大概都解决了,具体函数在那个文件可以搜一下(不在同一处)!
总结以上信息,供大家参考一下!