【问题标题】:Drupal 7 - How can I add a region inside another region?Drupal 7 - 如何在另一个区域内添加一个区域?
【发布时间】:2012-12-04 15:29:04
【问题描述】:

我很惊讶我在网上找不到这个问题的答案。

我目前正在为我的 drupal 站点创建一个自定义标头,因此我在 .info 和一个 region--custom-header.tpl.php 文件中创建了一个 custom_header 区域。在区域内,我需要添加另一个区域。

我尝试使用 -<?php print render($page['regionname']); ?> 打印标题区域内的其他区域,但没有显示任何内容。

好习惯与否,我该怎么做?

【问题讨论】:

标签: drupal drupal-7


【解决方案1】:

$page 在 region.tpl.php 文件中不可用(例如,在 node.tpl.php 中,它可用,但仅作为完整页面状态的标志,而不是包含区域信息的数组)。

要访问 region.tpl.php 中的任何区域,您应该通过预处理函数创建新变量。

添加到你的 template.php 文件中:

function youtheme_preprocess_region(&$variables) {
  $variables['regionname'] = block_get_blocks_by_region('regionname');
}

然后你可以像这样从这个区域输出内容:

echo render($regionname);

【讨论】:

    猜你喜欢
    • 2020-02-19
    • 2021-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多