[英]Where do PHP file corresponding to a twig files are stored in drupal 8
这是 page.html.twig 文件的一部分
<div class="content col-lg-{{ page.main_content_width }} col-md-{{ page.main_content_width }} col-sm-12 col-xs-12">
{{ page.highlighted }}
{{ title_prefix }}
{% if title %}
<h1>{{ title }}</h1>
{% endif %}
{{ title_suffix }}
{{ tabs }}
{% if action_links %}
<nav class="action-links">{{ action_links }}</nav>
{% endif %}
{{ page.content }}
{{ feed_icons }}
</div>
主题中没有命名为突出显示的块区域。 这些变量存储在哪里。我找不到这个树枝文件的 php 模板文件
这些变量是用可渲染数组生成的,您始终可以在相应的预处理挂钩中更改/查看它们。 在您的情况下, hook_preprocess_page
将向您显示树枝中使用的所有变量。
并回答您设置这些值的位置,文件/core/includes/theme.inc
function template_preprocess_page
正在准备这些变量。
function template_preprocess_page(&$variables) {
$language_interface = \Drupal::languageManager()
->getCurrentLanguage();
foreach (\Drupal::theme()
->getActiveTheme()
->getRegions() as $region) {
if (!isset($variables['page'][$region])) {
$variables['page'][$region] = array();
}
}
$variables['base_path'] = base_path();
$variables['front_page'] = \Drupal::url('<front>');
$variables['language'] = $language_interface;
// An exception might be thrown.
try {
$variables['is_front'] = \Drupal::service('path.matcher')
->isFrontPage();
} catch (Exception $e) {
// If the database is not yet available, set default values for these
// variables.
$variables['is_front'] = FALSE;
$variables['db_is_active'] = FALSE;
}
if ($node = \Drupal::routeMatch()
->getParameter('node')) {
$variables['node'] = $node;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.