Relevant / Similar content

Events happening in the community are now at Drupal community events on www.drupal.org.
mmartinov's picture

Those days a friend of mine come up with a question how to display a list of similar content bellow a node. He has researched and tested a bunch of modules, for example the relevant_content project, but it's giving a list of nodes with common taxonomy terms. What he wanted to show is a list with nodes having equal/similar values in their cck fields. I could create such a module but was wondering am I missing something?

Comments

comparison of similar modules

greggles's picture

There's a comparison of modules like that - http://groups.drupal.org/node/12347

The Recommender API is meant to be a general framework for building something like you describe since your idea is very specific (cck field).

You could probably also just use a view in a block and a sliver of custom code to get and pass in the appropriate argument to achieve what you describe.

Hey, thanks for the links and

mmartinov's picture

Hey, thanks for the links and the suggestions. Looks like there's a lot of effort in the field of content recommendations.
I was unable to find a suitable solution among the listed modules and I still think that writing a simple module that compares nodes according to values of cck fields is a good solution. Maybe I'll try to play a little bit with views arguments but I'm not sure it is worth it because it won't give me the flexibility I want. Say for example we have a content type with an integer cck field. We have a node where this field's value is 100. Now I want to display the similar nodes to the first one, which have the value of the same cck field set to something from 90 to 110. The views SQL query will look like "...WHERE field_value IN(90,91,92...109,110)..." which is very ugly. I could be wrong, maybe there is a way to build good queries through views, I don't have much experience with this module. It's quite the same for me if I have to click around half an hour to configure a view or I could write a custom module for the same time, with the benefit that my module will work faster than a view. But that's another story..

I've blogged about my try to

mmartinov's picture

I've blogged about my try to solve the issue with views based solution. The post is here: http://mmartinov.com/blog/similar-nodes-by-cck-fields

Could someone good with views just give me some hints if it's possible to alter the WHERE part of the SQL query in a way that it will search for a range, not for exact match. For example if we're comparing prices it'll be something like field_price BETWEEN 48000 AND 52000 or field_price > 48000 AND field_price < 52000 instead of field_price = 50000 or field_price IN (50000,50001,50002...)

  • Edit: I've just found out the answer to my question, it's hook_views_pre_execute(&$view).

Featured content

kristen pol's picture

I'm going back through old suggestions... it seems like views is your best bet because only you'll know how you want to compare the CCK fields.

Note that I wrote the Feature Content module to be a simple interface to creating quick featured/related blocks. I would be willing to expand this module to include more support for CCK fields if the functionality was well defined and useful for many people.

Right now, it does have support for CCK fields that are a:

  • node reference - grabs those related nodes
  • user reference - grabs nodes from those users
  • text field - parses text for node links (e.g. node/1, node/2)

Feel free to add a feature request for the Featured Content module if you can clearly define your needs and the functionality is pretty generic.

Kristen

Contributed Module Ideas

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: