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
Comment #1
druplicate commentedI tried another variant using html and tokens instead:
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.
Comment #2
druplicate commentedSolved 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);