Active
Project:
Views Custom Field
Version:
6.x-1.0
Component:
Miscellaneous
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Jan 2011 at 23:59 UTC
Updated:
9 Jun 2011 at 12:26 UTC
How do I pull in the node->uid of a node? I am currently working on displaying a grid of vendors for a site, and I need to test each vendor to find out if they are a favorite of the currently logged in user. Not sure exactly how to do it, but I'm using the Custom Field PHP, with the following code:
<?
global $user;
$runsql= "SELECT rid FROM {user_relationships} WHERE rtid = '1' AND requestee_id = %d AND requester_id = %d";
$fave = db_query($runsql, $node->uid, $user->uid);
if (($fave === false) || (is_null($fave))) {
$star = 'something';
}
else
{ $star = 'somethingdifferent';
}
?>
The issue is that I can't pull in node->uid. Any help?
Comments
Comment #1
FergalMohan commentedYou might need to call node_load first i.e.
$node = node_load($nid);
but be warned if you are previewing within Views it won't be set you need to test on the "real" view.