Drupal 视图拉取数据字段
我对 drupal 有点陌生,但一直在使用 devel 模块和主题开发人员等东西来加快学习过程。
我的问题是,是否可以从单个视图 tpl.php 页面甚至预处理中主题化整个视图块?
当我抓取 $view 对象时,我可以看到结果 $node->result,它具有所有结果,但它没有我的所有视图字段。我缺少诸如节点路径、分类标题和路径等内容。
根据我的理解,Drupal 希望您单独为每个输出字段设置主题。当我已经通过 $view 对象获得超过一半的结果时,创建如此多的额外模板似乎是多余的
通过字段输出节点会让这变得更容易吗?或者 $view->result 走错了方向?
谢谢!
I'm a little new to drupal but have been using things like devel module and theme developer to speed up the learning process.
My question, is it possible to theme an entire views BLOCK from a single views tpl.php page OR even a preprocess?
When I'm grabbing the $view object I can see results $node->result, it has all of the results, but it doesn't have all my views fields. I'm missing things like, node path, taxonomy titles and paths, etc.
From my understanding, Drupal wants you to individually theme EACH output field. It seems rather superfluous to create so many extra templates when I've already got over HALF of my results coming through the $view object
Would outputting node over field make this easier? Or am going in the wrong direction with $view->result?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此页面可能会有所帮助: http://drupal.org/node/342132
我很少以视图为主题字段级别——同意:需要编辑的文件太多。因此,我要么在节点/预告片级别执行此操作,要么以编程方式加载视图,然后将其显示在胶水模块的函数中。
是否执行节点或字段取决于您显示项目的其他方式。例如,如果您使用预告片的唯一方式是在此视图中,则它可能会简化在 node-mytype.tpl.php 文件中进行主题化的操作。如果您有四个不同的视图,并且所有视图都有不同的主题,则可以使用粘合模块方法。还有纯 CSS 方法。或者,有时,视图主题确实是最好的选择。
更新:您还可以在glue模块中使用node_load来获取更多节点信息。从性能角度来看,这可能会很昂贵,具体取决于视图的大小以及节点更改的频率。 (node_load 做了一些缓存...)
this page might help: http://drupal.org/node/342132
I rarely theme at the views field level -- agreed: it's too many files to edit. So I either do it at the node/teaser level, or load the view programmatically, and then display it in a function in my glue module.
whether to do nodes or fields depends on how else you're displaying the items. for example, if the only way you're using teasers is in this view, it might simplify things to do the theming in the node-mytype.tpl.php file. If you have four different views, all of which have different themes, you might use the glue module approach. There's also the css-only appraoch. Or, sometimes, views theming truly is the best option.
update: you can also use node_load in your glue module to get more node info. That can be expensive, performance-wise, depending on the size of your view and how often the nodes change. (node_load does some caching...)