I want to show related nodes to the current node in a block using taxonomy terms. In my site say x is my taxonomy vocabulary and x1,x2,x3,x4,x5,x6 and x7 are the taxonomy terms under it. A node could be tagged with any of these taxonomy terms. Say node T is tagged with x2 and x3. node W tagged with x3, x1 and x5. node c tagged with x2 and x6. node R tagged with x2 and x7. F tagged with x4,x6. H tagged with X2,x5. Now when the node T is displayed I want items having any of the taxonomy terms similar to the current node i.e. X2 or x3 but the priority should be x2 i.e. list all the related nodes with x2 as tag first and then only with x3. so in the above case i need related nodes in the order C R H W? How is it possible by using views in drupal 7?
-
Not sure how to do it with Views, but you can write a custom module: drupal.stackexchange.com/questions/32682/…– BeebeeCommented Apr 24, 2014 at 10:12
-
Possible duplicate of: drupal.stackexchange.com/questions/27844/…– BeebeeCommented Apr 24, 2014 at 10:13
-
There's also this module: drupal.org/project/similarterms– BeebeeCommented Apr 24, 2014 at 10:13
-
Thanks for the reply @Beebee. I had to write a custom module and it worked.– user3465250Commented Apr 29, 2014 at 4:30
1 Answer
There will be a significant amount of customization (in the form of a module) to get this done through views. I've created a sandbox module that you can install to get things working and so you can play around with it (see views.api.php in the views module).
Once enabled you should find a new contextual filter value called "The node whose taxonomies you want to relate". This contextual filter default will take the current node ID and return nids of nodes that share the same terms in vocabularies that you select. Therefore, please set the view display as a block.
If you need to know how to group by term using views, please see this answer.