显示相似节点
我今天在使用 Drupal 时遇到了一个问题。
我想在页面上显示一个节点(产品),并在该节点下方显示 3 个相似的节点(产品)。类似的是:具有相同的分类ID或附加有“升级”标签。
我尝试将相关节点制作成一个视图,仅当我们位于产品页面时,该视图才显示为块。我对此并没有深入了解。
我的第二个想法是制作一个面板页面,其中有两个视图,一个用于产品,一个用于相关产品。我对此也没有深入了解。
有谁知道实现此目标的最简单方法?
更新:
我已经尝试了这两个答案,但我没有收到任何相关产品。执行的 SQL 查询(术语 id = 1)是:
SELECT node.type AS node_type, node.title AS node_title, node.nid AS nid, node.created AS node_created FROM {node} node INNER JOIN {taxonomy_index} taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = :views_join_condition_0 WHERE (( (node.type IN ('product')) AND (taxonomy_index_value_0.tid AND '') AND( (taxonomy_index_value_0.tid IN ('1')) ))) ORDER BY node_created DESC LIMIT 10 OFFSET 0
当我手动执行查询并从查询中删除 AND (taxonomy_index_value_0.tid AND '')
时,我确实收到了相关产品。
有谁知道导致代码添加到查询中的原因以及如何修复它?
更新2: 我已删除“每个参数允许多个术语”,现在正在获取相关产品。但我不知道这对我的网站意味着什么。
更新3: 顺便说一句,我正在使用 Drupal 7。
I've somewhat ran in to a problem with Drupal today.
I would like to display a node (Product) on a page, and below that node, I'd like to display 3 similar nodes (Products). Similar being: having the same taxonomy id or having a "promoted" tag attached to it.
I've tried crafting the related nodes into a view which is being displayed as a block, only when we're on a product's page. I didn't get far with this.
My second thought was making a panel page with 2 views on it, one for the product, and one for the related products. I also didn't get far with this.
Does anybody know the easiest way to accomplish this?
Update:
I have tried both answers, I am not receiving any related products though. The SQL query that's executed (term id = 1) is:
SELECT node.type AS node_type, node.title AS node_title, node.nid AS nid, node.created AS node_created FROM {node} node INNER JOIN {taxonomy_index} taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = :views_join_condition_0 WHERE (( (node.type IN ('product')) AND (taxonomy_index_value_0.tid AND '') AND( (taxonomy_index_value_0.tid IN ('1')) ))) ORDER BY node_created DESC LIMIT 10 OFFSET 0
When I manually execute the query and remove AND (taxonomy_index_value_0.tid AND '')
from the query I do receive the related products.
Does anybody know what causes the code to be added to the query and how to fix it?
Update 2:
I've removed the "Allow Multiple Terms per Argument" and am now getting the related products. I don't know what this means for my site though.
Update 3:
I am using Drupal 7 by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用面板覆盖节点视图。并创建一个带有“taxonomy id argument”的视图块,您需要选择默认参数选项作为 PHP 代码并放置此代码。
我刚刚启动了一个使用面板+视图魔法的网站。 http://sgigulf.org/culture/synopsis-of-performers -由 sgi-gulf 展示
Override your node view with panels. And create a view block with 'taxonomy id argument', you need to choose default argument options as PHP Code and place this code.
I just launched a site using panels + views magic. http://sgigulf.org/culture/synopsis-of-performers-showcased-by-sgi-gulf
看一下相关内容模块。以下模块和一些教程的链接:
你说你显示器有问题。在这种情况下,请将上述说明中的视图设为一个块,并将其显示在节点内容下方的区域中,尽管这假设您的主题中有一个区域直接位于您的内容下方。
Take a look at the RelatedContent module. Links to the module and a couple of tutorials below:
You say you're having trouble with the display. In that casea, make the view from the above instructions a block, and have it display in a region that's below the node content, though that assumes there's a region in your theme directly below your content.
当您更改为“内爆”中的“+”是“或”时,您可以有多个项
。如果您想要 AND,则使用“,”代替
You can have multiple terms when you change to
The '+' in implode is OR. If you want AND, than use ',' instead