NodeReferrer module

Last updated on
30 April 2025

Documentation for NodeReferrer module http://drupal.org/project/nodereferrer .

What the module does:

NodeReferrer gives you a Read-only field that generates a list of all nodes referring to the current node (those using CCK node reference).
This list can be configured in order to limit what Content Types the referral links come from.

Case Scenario:

Let's say you have a Football website with two Content Types:

  • Stories (story) - everyday news items
  • Players (player) - static player profiles with name, age, team, photo, etc.

Let's also assume you already use CCK's node reference in order to make references from Stories to the Players.

This means everytime you post a new Story, there are links to the players involved.

All is cool... until you want the reverse action. To have links be shown on the Players pages for all the Stories they participate in.

Enter the NodeReferrer module.

Installation:

This module depends on CCK and CCK nodereference and is installed as any other Drupal module.

After enabling it:

  • Edit your your Content Type (eg. Players)
  • Go to Manage Fields and add a new field (type: Node Referrers), giving it any name (eg. field_inthenews).
  • Go thru the options (Referring Node Types, Referring Fields, Referrer Sort Order) and save.
  • Go to Display Fields and configure the way it is displayed.

If you are using customized Content Templates (Contemplate) you can use these Body variables:

<?php print $node->content['field_inthenews']['field']['#title'] ?>
<?php print $node->field_inthenews[0]['view'] ?>
// substitute field_inthenews with the name of your own field

After these simple steps you will have a list of "backlinks" on your Player pages. And that's about it!

Retrieve NodeReferrer's via Code

NodeReferrer has an internal function that can be used to retrieve referrers from relatively anywhere. Simply provide the nid and an array of fields and/or content types.

<?php $photos = nodereferrer_referrers($nid,array('field_photos_ref'),array('photo')); ?>

Views integration

NodeReferrer integrates with Views 2 and provides fields, filters and arguments that allow views to query the node's references by a certain node reference field or by a certain node type. Views Relationships support allows us to bring the node's referrers into the game and expand the view with fields, filters, arguments and sort criteria that are applied to the node's referrers.

Alternatives:

There are many alternatives to this module. One of them is the Backlinks module http://drupal.org/project/backlinks .

Note: Backlinks has been integrated into Views 2. So if you're using Views, chances are you already have it as one of the default views, you just have to enable it.

Help improve this page

Page status: Not set

You can: