A Drupal 7 branch has been created; however much work remains to port this module to Drupal 7 and the new Fields API. Patches and additional contributions are much welcome during this phase.

/Robin

CommentFileSizeAuthor
#2 node_reference_redirect.tgz640 bytese2thex
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

e2thex’s picture

Is there a reason for creating a whole new field type and not just creating a new display on the link or node_reference field?

e2thex’s picture

FileSize
640 bytes

Ok So i took a stab at making a formatter for the node reference field, I am thinking that this code be done for the link field as well.

I have attached module node_reference_redirect, that is very small and adds the formatter for node reference. Would you be intersted in going this way for the 7.x version?


/*
 * implements hook_field_formatter_info
 */
function node_reference_redirect_field_formatter_info() {
  return array(
    'rediect' => array(
      'label' => t('Redirect'),
      'field types' => array('node_reference'),
    ),
  );
}

/*
 * implements hook_field_formatter_view
 *
 * If we have a node reference and we can redirect to it lets do it!
 */
function node_reference_redirect_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

  $current_field = $entity->{$instance['field_name']};
  if(!empty($current_field) &&
     !empty($current_field[$langcode])) {
    $nid = $current_field[$langcode][0]['nid'];
    $path = "node/$nid";
    if(drupal_lookup_path($path)) {
      drupal_goto($path);
    }

  }
}

Anonymous’s picture

sub

DamienMcKenna’s picture

+1 for using the node_reference_redirect field formatter, and doing something similar for the Link field.

DamienMcKenna’s picture

I took e2thex's idea and ran with it: http://drupal.org/project/field_redirection

e2thex’s picture

@DamienMcKenna Sweet! Thanks

Anonymous’s picture

Works fine here. Thanks a lot.

chiappa’s picture

Module page says for CCK Redirection module:

Requires: Content (missing)

Even though I have installed and enabled: cck-7.x-2.x-dev.tar.gz (it's named CCK btw.)

How can I fix this dependency?

chiappa’s picture

Also if I enable the redirection module that comes with this, I get the following error message:

Deprecated function: Call-time pass-by-reference has been deprecated in drupal_load() (line 1105 of /home/mm4n/htdocs/takonoashi.net/project-mahorova/includes/bootstrap.inc).

chaboo’s picture

Hello,
I'm trying using ELMS distribution which requires redirection module.
Do you have any ideas about the release date ?
Thanking you in advance for your reply,