1

Is there anyway to sort the nodes on a views display using the amount of matching tags of a specif node? I would like to have a views display that shows me all the nodes that most match with a given node.

For example: I have one node with three terms associated with it and I'll pass this node to a views as an argument. The views should display first the nodes that have this same three terms, after that it should display the nodes which match with two of the three terms, after that the nodes that match one of the three terms and after that the nodes that doesn't match any of the three terms.

I couldn't find something that could solve this problem for me. If there isn't any implemented solution I'd like to know if it's feasible to implement this on Drupal 7.

1

2 Answers 2

4

Check out Similar by Terms module. This Drupal module attempts to provide context for content items by displaying a block with links to other similar content. Similarity is based on the taxonomy terms assigned to content. Blocks are available based on similarity within each of the defined vocabularies for a site as well as a block for similarity within all vocabularies. There are two methods of sorting. 1) Based on the most number of matching terms. 2) Based on lest used terms.

Or you could use the Relevant Content module. This module provides two ways of referencing relevant content. Both of these methods provide configuration to filter for specific content types and vocabularies, limit the maximum size of the result and provide some header text. The result on both cases are a list of nodes which the module considers most relevant based on the categorization of the current page. This is achieved by finding other nodes which are of one of the allowed types and have the most number of terms in common.

7
  • this two modules are a little bit buggy for drupal 7 and they don't really solve my problem. I would like some module that integrates with views and both of your solution don't. Aug 1, 2011 at 16:51
  • Do you have any idea on how hard would be to implement this sort on views 3.0 and drupal 7? Aug 1, 2011 at 17:21
  • Similar by terms is entirely built in views.
    – user842
    Aug 1, 2011 at 17:50
  • are you sure that the version for drupal 7 uses views? Aug 1, 2011 at 18:53
  • I have just downloaded and enabled the 7 version and it appears to be quite unstable (As per the description on the project's homepage). That being said, the 6 version was moved to a views plugin so it could be more flexible, so I would assume that the seven version, when solid, would be the same. You just may have to wait.
    – user842
    Aug 1, 2011 at 21:19
-1

I don't know if have a specific module to use, but I have two options, you can use query_alter to change the arguments, but I guess that you will need to execute the views other times to get the other results. Another option is execute a specific query to get a list of nids ordered by the sum of matching terms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.