在Drupal 7 / Views 3中创建类似节点的列表 [英] Creating list of similar nodes in Drupal 7/Views 3

查看:90
本文介绍了在Drupal 7 / Views 3中创建类似节点的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从drupal.stackexchange.com复制希望在这里获得更多的答案:

Copy from drupal.stackexchange.com hoping to get more answers here:

我面临一个相当常见的问题,显示类似于当前节点的节点列表。类似的节点被定义为具有当前节点具有的至少一个分类术语的节点。有几个解决方案可用作模块,但是我发现的模块(特别是按条款类似)在Drupal 7中处于测试阶段(如不能正常工作)。

I face a rather common problem of displaying a list of nodes similar to current one. Similar node is defined as one having at least one taxonomy term that current node has. There are few solutions available as modules, however the modules I've found (specifically Similar By Terms) are in beta stage (as in "not working properly") for Drupal 7.

我还发现了一些基于Views和上下文过滤器的解决方案(例如 http://scito.ch/content/show-related-nodes-block-based-taxonomy-terms-views-3-and-drupal-7 )或关系。我非常喜欢这种方式,因为它可以节省我安装额外的模块,并且正在积极开发和支持视图,我宁愿使用它们而不是任何定制解决方案。我无法解决的问题是如何按照共享条款的数量对类似节点进行排序。例如,如果我的iPhone 4S节点与小工具,苹果和电话有类似的节点,请按以下顺序:

I've also found a couple of solutions based on Views and contextual filters (such as http://scito.ch/content/show-related-nodes-block-based-taxonomy-terms-views-3-and-drupal-7) or relations. I quite like this way as it saves me installing extra modules and with Views being actively developed and supported I'd prefer to use them rather than any custom solution. The problem I can't get around is how to sort "similar nodes" by the number of terms they share. For example, if I have "IPhone 4S" Node with Terms "Gadget", "Apple", and "Phone", I want similar nodes in the following order:


  1. iPhone 3(Apple,Gadget,Phone)

  2. IPad(Apple,Gadget,Tablet)

  3. <计算机)
  4. Bramley(Apple,Fruit,Tree)

  1. IPhone 3 (Apple, Gadget, Phone)
  2. IPad (Apple, Gadget, Tablet)
  3. Mac (Apple, Computer)
  4. Bramley (Apple, Fruit, Tree)

这个观点按照他们分享的数量?

How can I sort nodes in this view by the number of terms they share?

这个问题是关于构建视图,请不要建议模块或自定义基于PHP的解决方案。谢谢。

This question is about building a view, please do not suggest module or custom php-based solutions. Thank you.

推荐答案


  1. 创建块视图

  2. 添加内容过滤器 - >内容:Nid - >提供默认值 - > URL中的内容ID

  3. 添加关系 - >内容:节点上的分类术语 - >指定适当的词汇

  4. 添加关系 - >分类术语:使用上面指定的词汇内容 - >检查需要这种关系

  5. 打开视图聚合(注意:屏幕截图中的箭头以下是指向错误的地方,应该指向下方的2行)

  6. 假设您仅列出标题,请编辑标题字段以使用您在#

  7. 添加新内容的排序条件:Nid。在聚合设置中,选择计数。使用关系从#4和排序

  8. 添加内容相关过滤器 - >内容:Nid - >使用关系从#4 - >提供默认值 - 内容ID从URL - >向下滚动并展开更多,然后选择排除从视图中删除当前节点

  1. Create a block view
  2. Add Contextual filter -> Content: Nid -> Provide default value -> Content ID from URL
  3. Add Relationship -> Content: Taxonomy terms on node -> specify the appropriate vocabulary
  4. Add Relationship -> Taxonomy term: Content using vocabulary as specified above -> Check off Require this relationship
  5. Turn on Views aggregation (NOTE: the arrow in the screenshot below is pointing to the wrong spot and should be pointing to 2 rows below where it is)
  6. Assuming you are listing title only, edit the title field to use the Relationship you set up in #4 above.
  7. Add new sort criteria of Content: Nid. In aggregation settings, select Count. Use relationship from #4 and sort descending
  8. Add Contextual filter -> Content: Nid -> Use relationship from #4 -> Provide default value - Content ID from URL -> Scroll down and expand "More" then check "Exclude" to remove current node from the view

**请参阅下面的@ garret-albright的评论进行测试这在Views UI预览中。 **

** See comment by @garret-albright below for testing this in the Views UI preview. **

这篇关于在Drupal 7 / Views 3中创建类似节点的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆