显示类似的节点 [英] Displaying similar nodes

查看:164
本文介绍了显示类似的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天遇到了一个Drupal的问题。



我想在页面上显示一个节点(Product),在该节点下方,我想显示3个类似的节点(产品)。类似的是:具有相同的分类标识或附加了升级标签。



我已经尝试将相关节点制作为正在显示为一个块,只有当我们在产品的页面上。我没有这么远。



我的第二个想法是制作一个面板页面,其中有两个视图,一个用于产品,一个用于相关产品。我也没有这么远。



有没有人知道最简单的方法来完成这个?



更新:



我已尝试过两个答案,但我没有收到任何相关产品。执行的SQL查询(term 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

解决方案

使用面板覆盖您的节点视图。并且使用'taxonomy id argument'创建一个视图块,你需要选择默认的参数选项作为PHP代码并放置这个代码。

  $ node = node_load(arg(1)); 
if($ node){
foreach($ node-> taxonomy as $ term){
$ term = $ term-> tid;
return $ term;
}
}

我刚刚推出了一个使用面板+视图魔术的网站。 http://sgigulf.org/culture/synopsis-of-performers -showcased-by-sgi-gulf


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.

解决方案

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.

$node = node_load(arg(1));
if($node) {
    foreach($node->taxonomy as $term) {
        $term = $term->tid;
        return $term;
    }   
}

I just launched a site using panels + views magic. http://sgigulf.org/culture/synopsis-of-performers-showcased-by-sgi-gulf

这篇关于显示类似的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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