Drupal 视图:如何为两个视图放置一个包装 div?
我在 Drupal 页面中有两个具有以下结构的视图:
<div>
<div>Some content</div>
<div> View 1 </div>
<div> View 2 </div>
</div>
现在我想要一个覆盖这两个视图的包装 div:
<div>
<div>Some content</div>
<div class="wrapper">
<div> View 1 </div>
<div> View 2 </div>
</div>
</div>
最好和最简单的方法是什么?
I have two views in a Drupal page with the following structure:
<div>
<div>Some content</div>
<div> View 1 </div>
<div> View 2 </div>
</div>
Now I want a wrapper div covering the two views:
<div>
<div>Some content</div>
<div class="wrapper">
<div> View 1 </div>
<div> View 2 </div>
</div>
</div>
What is the best and easiest way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更简洁的方法是使用
views_embed_view
函数获取输出两个视图,然后将其包装在一个 div 中。将此代码放在哪里以及如何执行取决于您现在的工作方式。您可以为其创建一个块并获得块的灵活性。
A cleaner way would be to use the
views_embed_view
function to get the output from the two views, which you then wrap in a div.Where to put this code and how to do it, would depend on how you are doing things now. You could create a block for it and gain the flexibility of blocks.
您需要为此创建一个自定义 .tpl 文件。它类似于但不完全是:
要查找文件名,请编辑视图,然后在“基本设置”>“基本设置”下查看。主题。
You'll want to create a custom .tpl file for this. It would be something like, but not exactly:
To find the file name, edit the views then look under Basic Settings > Theme.
您还可以使用视图附件(Google 一下以了解如何制作它们)。因此,将视图 1 设为普通视图,并将视图 2 附加到视图 1 的之后。您将在这两个视图周围获得一个包装 div。
You can also use Views attachments (Google around to figure out how to make them). So make View 1 a normal view and attach View 2 to appear after View 1. You will get a wrapper div around both the views.