Drupal 区域与区域内
我知道有关在 page.tpl.php 甚至 Drupal 6 中的 node.tpl.php 上添加区域的所有信息。但是,我有一个特殊情况,我需要在另一个区域中添加区域。
在我的 Drupal 安装中,我发现了 Region.tpl.php 文件,如下所示:
<div class="<?php print $classes; ?>">
<?php print $content; ?>
</div><!-- /.region -->
我修改了它以输出我的自定义区域:
<div class="testing <?php print $classes; ?>">
<?php print $content; ?>
<?php if ($inner_sidebar_right): ?>
inside inner-sidebar-right
<div class="inner-sidebar-right"><?php print $inner_sidebar_right; ?></div>
<?php endif; ?>
这不起作用。
ps:在node.tpl.php中添加区域时,您必须在template.php中操作_preprocess_node。 是否有一个 _preprocess_region 函数可以帮助完成此任务?
I know all about adding a region on page.tpl.php and even node.tpl.php in Drupal 6. But, I have a special case where I need to add a region within another region.
In my Drupal install I found the region.tpl.php file which looks like the following:
<div class="<?php print $classes; ?>">
<?php print $content; ?>
</div><!-- /.region -->
I amended it to output my custom region:
<div class="testing <?php print $classes; ?>">
<?php print $content; ?>
<?php if ($inner_sidebar_right): ?>
inside inner-sidebar-right
<div class="inner-sidebar-right"><?php print $inner_sidebar_right; ?></div>
<?php endif; ?>
It doesn't work.
ps: When adding regions in node.tpl.php you have to manipulate _preprocess_node in template.php.
Is there perhaps a _preprocess_region function to help accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 drupal_get_region_content() 加载任何地区的内容。因此,理论上您可以在模板的开头添加以下代码行以获得所需的结果:
但是,正如您原始帖子的评论中所提到的,我不建议将此作为理想的解决方案。根据您的最终目标,很可能有一种更优雅的方法来实现这一目标。
You can use drupal_get_region_content() to load the content for any region. So you could theoretically add the following line of code at the beginning of your template for the desired result:
However, as mentioned in the comments to your original post, I would not recommend this as an ideal solution. Depending on your end goal, there is most likely a more graceful way to accomplish this.