CCK 字段和视图之间的链接
我想使用视图来选择内容类型字段中的节点。该视图必须接收一个作为内容类型的另一个字段的参数。 有人可以解释一下如何将参数从现场传递到视图吗?
原谅我糟糕的英语
I want to use a view to select nodes in a content type field. This view must receive an argument that is another field of the content type.
Can someone explain me how to pass the argument from the field to the view?
Excuse my poor english
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您也许可以使用视图参数附加模块。它将允许视图的参数来自 cck 字段。有关此模块的更多详细信息(来自其项目页面):
You might be able to use the Views Arguments Extras module. It will allow the argument of the view to come from a cck field. Some more details about this module (from its project page):
我相信您可以使用参数验证来验证参数,此时您可以在 $handler->argument 值传递到视图之前自由更改它。
I believe you can use the argument validation to validate the argument, and at that point you are free to change the $handler->argument value before it is passed in to Views.
如果您只想根据 CCK 字段的值更改视图显示的内容,我发现的最简单的方法是使用
views_embed_view()
将视图嵌入到模板中。我认为模板文件中类似的东西会起作用:views_embed_view()
只需要第一个参数(视图的名称)即可工作。它将返回指定视图的默认显示的 HTML。我们将特定的显示作为第二个参数传递给它。第二个参数之后的任何内容都会作为参数传递到视图中,因此我们将字段的值作为参数传递给视图。请参阅此链接,获取有关该函数如何工作的一些文档。If you just want to change what the view displays based on the value of a CCK field, the easiest way I have found is to embed a view into the template using
views_embed_view()
. Something like this in your template file would work I think:views_embed_view()
only needs the first argument, the name of the view, to work. It will return the HTML for the default display of the named view. We pass it a specific display as a second argument. Anything after the second argument gets passed into the view as an argument, so we pass in the value of the field as an argument to the view. See this link for some documentation on how the function works.