Displaying similar nodes

后端 未结 3 674
花落未央
花落未央 2021-01-29 04:25

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 (Pro

相关标签:
3条回答
  • 2021-01-29 04:49

    You can have multiple terms when you change to

    $node = node_load(arg(1));
    if ($node) {
        $ret = array();
        foreach ($node->taxonomy as $term) {
            $ret[] =  $term->tid;
        }   
        return implode('+', $ret);
    }
    return '';
    

    The '+' in implode is OR. If you want AND, than use ',' instead

    0 讨论(0)
  • 2021-01-29 05:01

    Take a look at the RelatedContent module. Links to the module and a couple of tutorials below:

    • http://drupal.org/project/relatedcontent
    • http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-create-a-related-pages-block
    • http://www.hankpalan.com/blog/drupal/related-content-views-2-drupal

    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.

    0 讨论(0)
  • 2021-01-29 05:02

    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

    0 讨论(0)
提交回复
热议问题