This was originally a support question (http://drupal.org/node/767334) but I'm reissuing it as a bug.

The following custom PHP code does not work. The goal is to allow the user to input an ID number in a field in a block with a submit button using an exposed filter for that CCK field. Then the custom code executes a page redirect to the node corresponding to the entered ID number (there is a one to one correspondence of this ID number and the NID) Views runs the query and should supply the nid to the custom code but it doesn't make it.
<?php drupal_goto('node/'. $view->result[0]->nid);?>

Even this doesn't work - prints nothing:<?php print $view->result[0]->nid;?>

This code does work:<?php drupal_goto('node/'. '5432');?>

Why doesn't PHP code have access to the NID?

I can't use tokens in PHP

Comments

druplicate’s picture

I tried another variant using html and tokens instead:

<html>
<head>
<meta http-equiv="REFRESH" content="0;url=http://192.168.1.12/node/[nid]">
</head>
</html>

That doesn't work either.
The input filter is set to full html.
Tried it in "rewrite this field..." and "value" sections.

I also tried this using the Views "global" text field and it doesn't work either. But replacing [nid] with 5432 also doesn't work.

druplicate’s picture

Status: Active » Fixed

Solved it!

Just noticed when I add a customfield to the view, there's a little note that says I should be using $data->nid.

This code now works:

drupal_goto('node/'. $data->nid);

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.