如何在模板中使用drupal_view两次或更多内容显示/打印相同的内容?

发布于 2025-02-10 23:42:36 字数 184 浏览 3 评论 0原文

我有一个页面,需要两次显示/打印相同的内容。为此,我正在使用drupal_view。

{{ drupal_view('product_content', 'page_1', node.id) }}

该代码仅适用于第一个位置,对于第二个位置,它不起作用。可以做什么,以使内容在两个地方都显示?

I have a page where I need to show/print the same content twice. For this, I am using drupal_view.

{{ drupal_view('product_content', 'page_1', node.id) }}

This code works only for the first position and for the second position it doesn't work. What can be done so that the content shows up in both places?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

半步萧音过轻尘 2025-02-17 23:42:36

从Drupal社区获得了解决方案:

当渲染内容时,渲染系统记得
渲染,不会重新渲染它。将渲染输出分配给树枝
变量并两次打印变量:

> {% set product_content = drupal_view( ... )|render %}
> {{ product_content }} 
> {{ product_content }}

Got the solution from the Drupal community:

When something is rendered, the render system remembers what has been
rendered and won't re-render that. Assign the render output to a twig
variable and print the variable twice:

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