多值字段的主题视图
我知道这可能是一个n00b问题,但我到处寻找答案但没有找到任何东西。
我有一个“功能”的 CCK 多值字段,其中产品可以输入随机数量的多个功能。我正在编辑视图,以便可以在产品页面上设置功能输出的样式。
现在,在我看来,我可以使用以下命令立即输出整个功能列表:
<?php print $fields['field_features_value']->content ?>
这将为我提供产品给出的所有功能的列表。但我想做的是循环遍历并提取每个单独的功能,并分别对其进行格式化/样式设置。我到底该怎么做呢?
I know this is probably a n00b question but I've searched everywhere for an answer and havent found anything.
I have a CCK multiple value field for "Features" where a product can have a random number of multiple features entered for it. I am editing the view so I can style the output of the features on the product page.
Right now in my view I can output the entire list of features at once using:
<?php print $fields['field_features_value']->content ?>
This will give me a list all the features given for a product. But what I want to do is loop through and pull out each individual feature and format/style it separately. How exactly would I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我昨天再次遇到这个问题,花了几个小时尝试谷歌语法,但无济于事。
我能够让它发挥作用,但我必须承认这不是最好的方法。它重复了 Views 已经为我们完成的一些工作,并且应该被视为一种强力方法。
我的用例涉及对节点中每个基于节点的行单独设置每个文件字段文件的主题:
我使用了 Devel 这里大量使用模块(附加了此示例的图像参考),以便获得我需要的嵌套值。
我知道有一种更好、更正确的方法来执行此操作,而不是重新加载节点数据,因为视图应该在页面加载时已经可以访问它。
I ran into this yesterday again, and spent hours trying to Google the syntax, to no avail.
I was able to get this to work, but I must admit it is not the best way. It is duplicating some of the work that Views has already potentially done for us, and should be considered a brute-force approach.
My use case involved theming each filefield file in a node separately, per node-based row:
I used the Devel module heavily here (image reference for this example attached), in order to get the nested values I needed.
I know there is a better, proper way of doing this, rather than reloading the node data, since views should already have access to this upon page load.
当主题视图过于具体时,我会设置条件、关系、参数和所有视图内容除了字段。我使用的唯一字段是节点 ID。
然后,在进行主题化时,我使用...
...来获取节点对象。您可以使用 devel 模块附带的 dpm 函数检查节点对象。
这种“技术”适用于节点,并且当您不关心优化或速度时,因为如果您要使用 1000 个节点执行此操作,则应该批量加载节点。
When theming views is too specific I set conditions, relationships, parameters and all the views stuff except fields. The only field I use is node id.
Then when doing the theming I use...
... to get the node object. You can inspect the node object with the dpm function that comes with the devel module.
This "technique" works well for nodes and when you don't care about optimization or speed, because if you are going to do this with 1000 nodes you should load the nodes on batch.