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

查看:19
本文介绍了在 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.

我还发现了一些基于视图和上下文过滤器的解决方案(例如 http://scito.ch/content/show-related-nodes-block-based-taxonomy-terms-views-3-and-drupal-7) 或关系.我非常喜欢这种方式,因为它节省了我安装额外模块的时间,并且随着 Views 的积极开发和支持,我更喜欢使用它们而不是任何自定义解决方案.我无法解决的问题是如何根据相似节点"共享的术语数对它们进行排序.例如,如果我有带有术语Gadget"、Apple"和Phone"的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(苹果、小工具、手机)
  2. iPad(苹果、小工具、平板电脑)
  3. Mac(苹果、电脑)
  4. Bramley(苹果、水果、树)

如何在此视图中按节点共享的术语数对节点进行排序?

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. 假设您仅列出标题,请编辑标题字段以使用您在上面第 4 条中设置的关系.
  7. 添加新的内容排序标准:Nid.在聚合设置中,选择计数.使用 #4 中的关系并降序排序
  8. 添加上下文过滤器 -> 内容:Nid -> 使用 #4 中的关系 -> 提供默认值 - URL 中的内容 ID -> 向下滚动并展开更多",然后选中排除"以从视图中删除当前节点

** 请参阅下面@garret-albright 的评论,以在视图 UI 预览中对此进行测试.**

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

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

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