Drupal 查看输出
首先我要说的是,我试图找到主题视图的最佳实践,这一直是一种折磨,在 Drupal 中似乎有一百万种方法可以做任何事情,没有一种比另一种更好……但这就是问题所在。
我正在开发一个网站。网站的每个“区域”都有自己的内容类型。每种内容类型都有自己的具有多个显示的视图。
我使用行样式:节点。我可以使用 NODE-VIEW-VIEWNAME.tpl.php 为完整节点设置主题,但如何为各个显示设置主题?
视图建议我在“主题信息”区域中使用节点模板,这就是我所做的。我想它只是 NODE-VIEW-VIEWNAME--.... 但不确定。
提前致谢。
First let me start by saying that Im trying to find the best practices in themeing views and it has been torture, its seems theres a million ways to do anything in Drupal and none better than the other... but heres the issue.
Im developing a site. Each "area" of the site will have its own content type. Each content type will have its own VIEW with multiple displays.
Im using ROW STYLE: NODE. I can theme the FULL NODE using NODE-VIEW-VIEWNAME.tpl.php, but how would I theme the individual displays?
Views suggests that I use node templates in the "Theme Information" area so thats what Im doing. I suppose that it would just be NODE-VIEW-VIEWNAME--.... but not sure.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用模板是一种可行的方法,除非您想要一个具有条件语句的视图来测试真正应该加载的页面布局。但保持第三方PL 的隔离确实是件好事。
为了减少模板数量。我会查看您的所有视图和节点类型,并查找哪些视图和节点类型具有共同的布局和数据。然后尝试找出需要多少个视图,并从影响最大的视图开始(可用于大多数节点类型和情况)。这应该可以缓解整个主题中模板文件混乱的问题。
要了解如何执行此操作,您应该首先阅读这篇文章(对我帮助很大),它清楚地讨论了用于定位最大且正确的视图页面集的视图和命名约定。
还有更多资源可供您借鉴:
干杯!
Using templates is the way to go, unless you want to have a view that has conditional statements to test what page-layout really should be loaded. But keeping isolated tpl's can be really good.
For the sake of reducing the amount of templates. I would look across all your views and node types and look for which one have a layout and data in common. Then try to find how many views would be needed and start with the on that has highest impact (can be used for most node types and situations). That should mitigate the problem of having messy template files all over your theme.
To understand how to do this you should first read this article (helped me a lot) that clearly talks about views and naming conventions to be used to target the maximum and correct set of view pages.
There also more resources for you to draw from:
Cheers!
如果您发现查看主题是一项艰巨的挑战,我建议您看看显示套件模块。它与视图结合使用时效果非常好,允许您为视图创建多种视图模式,每种模式都具有不同的布局和包含的字段集。然后,可以使用相同的主视图轻松地为不同的块创建替代布局。不需要复杂的模板代码。
If you find View themes a difficult challenge I suggest you take a look at the Display Suite module. It works extremely well when combined with with views, allowing you to create multiple view modes for a view, each with different layouts and included field sets. Then alternate layouts can easily be created for different blocks using the same master view. No complicated template code required.