简体   繁体   English

如何在Drupal 7视图中显示Webform

[英]How to display webform in drupal 7 views

I created webform as block and I'm rendering in template like: 我创建了webform作为块,并在模板中进行渲染:

<?php print render($page['contact_us']); ?>

This working fine in .php, but in views not working. 这在.php中工作正常,但在视图中不起作用。

I would say that you are rendering region that contains your block, not the block it self and you placed that block in "contact_us" region. 我要说的是,您正在渲染包含您的块的区域,而不是其自身的块,并且您将该块放置在“ contact_us”区域中。 But regions are available only in your page template. 但是区域仅在您的页面模板中可用。

Check out how to render block directly: 查看如何直接渲染块:

https://www.drupal.org/node/26502 https://www.drupal.org/node/26502

So, it should be like: 因此,它应该像:

$block = module_invoke('module_name', 'block_view', 'block_delta');
print render($block['content']);

And module name should be "webform". 并且模块名称应为“ webform”。 You can place this code directly in your view template, where you want your webform block rendered or in pre-precess function and then pass to your template as some variable and print it there. 您可以将此代码直接放置在您希望在其中渲染Webform块的视图模板中或在前置函数中,然后将其作为一些变量传递到模板并在其中打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM