When a visitor goes node/123, I need them to be redirected to the url that is specified in that node's cck field. I know there are plenty of modules that do redirects, but I need this specific type of automation. What would be the best way to go abut this?


There is multiple way of doing this. Probably the best one is create a custom module and

Using hook_menu_alter(), alter the page callback for node/%node. In your page callback, check the type of the node to invoke node_page_view on the node or redirect to the referenced node.

MODULE_menu_alter(&$items) {
  $items['node/%node']['page callback'] = 'MODULE_node_page_view';

MODULE_node_page_view($node) {
  if ($node->type == MODULE_NODE_TYPE) {
    //if fixed_x is a node nid
    $reference = $node->field_x;
    drupal_goto('node/'. $referenced_node->nid);
    //if fixed_x is a path
  else {
    return node_page_view($node);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.