My BlogAbout MePortfolioTemplatesArticlesWeb StoreMessage Board (Forums)Guestbook

Recommended Stuff

Browse archives

September 2012  
Mo Tu We Th Fr Sa Su
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Search this site with Google

Related Nodes - my first Drupal module

Submitted by Jakob on 6 May, 2006 - 12:52.My Blog | Drupal

Many blogs list related blog entries as "Related Articles", however currently this isn't something that Drupal supports, nor could I find a module that does. It seemed I would have to write my own module, so yesterday I started working on what was to become my first Drupal module. It's called 'Related Nodes'.

Related Nodes is based on this code snippet for showing other nodes that have certain taxonomy terms associated with them. Problem with the snippet is that it doesn't use the terms associated with the current node being viewed nor can you specify what node types you want it to show which is why I decided to write a module.

The decision to develop it as a module rather than as a block was because a block's content would inevitably appear after $content in the template, so comments, links and the trackback would appear above it. I need the list to appear directly under the node's content. The purpose of the list of related articles is to present relevant content and there's no point in that if people don't see it, is there?

The module works in the fashion that every node type for which you have enabled it, it will, at the end of the node's content show a list of eight (default value, but you can configure it) other nodes. What nodes are being listed is determined by:

  • whether the node to be listed shares terms with the current node (the node being viewed)
  • whether its node type is one of the node types selected to be listed as a related node

So the listed nodes are nodes that share terms with the node being viewed, but not just any terms. Since many websites use taxonomy vocabularies to structure content and many nodes might possible share terms but still not have the kind of relationship we're looking for here, I've limited this to one vocabulary. At my site I use the vocabulary I call Topics to find other nodes of the type "personal blog entry" that are about one or several of the topics (Topics vocabulary terms) the current node is associated with.

The module isn't complete yet, work remains but it's complete enough to be used here and will be released eventually. You can see some examples of it in action on another node, not this one however as at the time of writing no other nodes are associated with the same terms.

Plans for other features:

  • possibility for configuring what node types to be listed on a per current node's node type basis
  • when no nodes are found, list random nodes
  • possibility to show teaser, or part of teaser 

Trackback URL for this post:
Submitted by fgm (not verified) on 9 May, 2006 - 14:46.

You might want to compare this to similar.module, which seems to do what you're looking for, doesn't it ?

Submitted by Jakob on 9 May, 2006 - 14:59.

Thanks for posting. It doesn't really work in the same fashion as related_nodes.module, they complete each other. For sites that do not use taxonomy terms so strictly as I do, and which have forums, similar_entries.module would probably work great for support forums and such where people often need to find posts that are similar to the one they're reading.

"The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is, the search for a superior moral justification for selfishness." - John Kenneth Galbraith

Post new comment

The content of this field is kept private and will not be shown publicly.


  • Web and e-mail addresses are automatically converted into links.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Verify comment authorship
Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.