Hi everyone;

I have an interesting problem.
I try to build some kind of related content block.

Sortly, I use tags as a channels/catagories. For example; there is a content like best Spanish football clubs and this content got three tags; Barcelona, Real Madrid, Atl. Madrid.

For me, this three tags are channels and they got own pages. I try to find related channels with the best way.

I add a image (http://i61.tinypic.com/2vc9m9u.jpg) and try to explain there. I give a example with three content.
That i need is last part of image, means counts of tags.
By this way i understand blue is most related with green.. after that yellow. Because many times they have taken place with together.

I am aware of this is unusual method and for this i cant answer anywhere.

Please help me, thanks :)

Comments

Stefan Lehmann’s picture

That's a pretty interesting problem and I'm not sure if there is an easy answer for it. I can't think of a solution which would work on the fly anyway, as you really have to iterate through all the content and count the relationships from the perspective of each term. My head explodes when I even think about it .. :D

However I had a short thought about (head is still working) this and I could see something working like this:

  • Add an unlimited entity reference field to your taxonomy terms and call it something like: Weighted relationship
  • Create a cron task which runs over all nodes and does the hard job of finding out which term is related to which and how heavy that particular relationship is. At the end of the cron all the relationships in: term -> Weighted relationship get removed and then rewritten. The first term in the Entity reference list is the heaviest relationship (eg: Blue -> Green), the second one is the second heaviest one (eg. Blue -> Yellow) and so on. The cron then runs however often you need it, but you have to keep in mind, that this task will get more and more difficult the more nodes & tags you have to evaluate. I probably would have some kind of helper table, to cache the intermediate results .. not sure.
  • Build a View which takes the "Weighted relationship" field into account .. Not sure how that would look like, but it should be reasonably straight forward.

Of course this solution is not a real time one, but finding the weighted relationships between all tags on each page request would be quite a big job and I don't think it would scale very good. I might be wrong, but that's what my gut tells me.

Good luck!

I like cookies!