Drupal 区域与区域内

发布于 2024-11-18 19:19:46 字数 756 浏览 10 评论 0原文

我知道有关在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮坠入山谷 2024-11-25 19:19:46

您可以使用 drupal_get_region_content() 加载任何地区的内容。因此,理论上您可以在模板的开头添加以下代码行以获得所需的结果:

<?php $inner_sidebar_right = drupal_get_region_content('inner_sidebar_right'); ?>

但是,正如您原始帖子的评论中所提到的,我不建议将此作为理想的解决方案。根据您的最终目标,很可能有一种更优雅的方法来实现这一目标。

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:

<?php $inner_sidebar_right = drupal_get_region_content('inner_sidebar_right'); ?>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文