如何在drupal中使用节点标题作为上下文过滤器(How can I use the node title in drupal as a contexual filter)

编程入门 行业动态 更新时间:2024-10-27 20:29:24
如何在drupal中使用节点标题作为上下文过滤器(How can I use the node title in drupal as a contexual filter)

我正在电影网站上工作,我有两种内容类型,“电影”和“电影评论”。 我想制作一个视图(使用视图模块),向我展示与电影相关的所有“电影评论”。

我需要抓住所有“标题”cck字段中具有相同内容的“电影评论”作为当前“电影”节点的标题。

即如果我正在观看“马达加斯加”电影节点,我需要在标题中获得所有带有“马达加斯加”的电影评论。

可以这样做吗?

I'm working on a movie website and I have two content types, "Movies" and "Movie reviews". I want to make a view (using the views module) that shows me all of the "Movie Reviews" related to a movie.

I need to grab all the "Movie Reviews" that have the same content in the "Title" cck field as the title of the current "Movie" Node.

i.e. if I am viewing the "Madagascar" Movie node, I need to get all of the Movie Reviews with "Madagascar" in the title.

Can this be done?

最满意答案

您最好使用实体引用字段。

安装此http://drupal.org/project/entityreference 将实体引用字段添加到引用电影内容类型的审阅内容类型。 创建一个显示评论列表的新视图。 添加一个上下文过滤器,选择影片字段,其中显示“WHEN”过滤器值不可用“选择提供默认值 - > URL中的内容ID。

如果您创建了带有块的视图,则可以在电影页面上看到该块,并且它应该只显示链接到该电影的评论

You would be better off using an entity reference field.

Install this http://drupal.org/project/entityreference Add an entity reference field to your review content type that references the movie content type. Create a new view displaying a list of reviews. Add a contextual filter selecting the movie field, where it says "WHEN "THE FILTER VALUE IS NOT AVAILABLE" select Provide default value -> Content ID from URL.

If you have created the view with a block place the block so it can be seen on the movie page and it should only display reviews linked to that movie

更多推荐

本文发布于:2023-07-07 15:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1065192.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上下文   节点   过滤器   标题   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!