如何快速主题视图? [英] How to quickly theme a view?
问题描述
我已经用 CCK 和 View 2 模块定义了一个视图.我想快速定义一个特定于此视图的模板.有没有这方面的教程或信息?我需要修改哪些文件?
I've defined a view with the CCK and View 2 modules. I would like to quickly define a template specific to this view. Is there any tutorial or information on this? What are the files I need to modify?
这是我的发现:(已编辑)
实际上,有两种方法可以为视图设置主题:field"方式和node"方式.在编辑视图"中,您可以选择Row style: Node
"或Row style: Fields
".
In fact, there are two ways to theme a view: the "field" way and the "node" way. In "edit View", you can choose "Row style: Node
", or "Row style: Fields
".
- 使用Node"方式,您可以创建一个node-contentname.tpl.php,它将为视图中的每个节点调用.您将可以使用 $field_name[0]['value'] 访问您的 cck 字段值.(edit2) 您可以使用 node-view-viewname.tpl.php,它只会为从此视图显示的每个节点调用.
- 使用字段"方式,您可以为要单独设置主题的每个字段添加一个视图视图字段--视图名称--字段名称-值.tpl.php.莉>
- with the "Node" way, you can create a node-contentname.tpl.php which will be called for each node in the view. You'll have access to your cck field values with $field_name[0]['value']. (edit2) You can use node-view-viewname.tpl.php which will be only called for each node displayed from this view.
- with the "Field" way, you add a views-view-field--viewname--field-name-value.tpl.php for each field you want to theme individually.
感谢之前的回复,我使用了以下工具:
Thanks to previous responses, I've used the following tools :
- In the 'Basic Settings' block, the 'Theme: Information' to see all the different templates you can modify.
- The Devel module's "Theme developer" to quickly find the field variable names.
- View 2 documentation, especially the "Using Theme" page.
推荐答案
实际上有两种方法可以为视图设置主题:field"方式和node"方式>"的方式.在编辑视图"中,您可以选择Row style: Node
"或Row style: Fields
".
In fact there are two ways to theme a view : the "field" way and the "node" way. In "edit View", you can choose "Row style: Node
", or "Row style: Fields
".
- 使用Node"方式,您可以创建一个node-contentname.tpl.php,它将为视图中的每个节点调用.您将可以使用 $field_name[0]['value'] 访问您的 cck 字段值
- 使用字段"方式,您可以为要单独设置主题的每个字段添加一个视图视图字段--视图名称--字段名称-值.tpl.php.莉>
- with the "Node" way, you can create a node-contentname.tpl.php wich will be called for each node in the view. You'll have access to your cck field values with $field_name[0]['value']
- with the "Field" way, you add a views-view-field--viewname--field-name-value.tpl.php for each field you want to theme individually.
感谢之前的回复,我使用了以下工具:
Thanks to previous responses, I've used the following tools :
- In the 'Basic Settings' block, the 'Theme: Information' to see all the different templates you can modify.
- The Devel module's "Theme developer" to quickly find the field variable names.
- View 2 documentation, especially the "Using Theme" page.
这篇关于如何快速主题视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!