How do i get UID from current Node / content and if no UID then UID =1 in a block

Comments

incom’s picture

How do i get profile_field_name (profile_values) of current node in a block

praveen-sl’s picture

your questions are not informative at all. please explain further.

--
Praveen Gunasekara

incom’s picture

when a node is displayed i want to call the user profile field values in a block to show his contact details like email , phone etc

praveen-sl’s picture

hi incom,

you have two options.
1. nodeapi
2. node.tpl.php
3. blocks

yes you can either use nodeapi hook with operation = view or you can edit node.tpl.php directly.

but if you want it in a block then you first have to check for the url. for ex.
?q=node/24

then first check this with arg() function and then use a sql to get the uid of that specific node id.

and then use that uid to get the relavant profile values.

hope this will help you.

--
Praveen Gunasekara

incom’s picture

Thank you Praveen.

if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
  $node = node_load(arg(1));
  
$sql = "SELECT value FROM profile_values WHERE (uid = $node->uid) AND (fid = 2)"; //'2' is MY location field... it may not be the same as yours.'
$result = db_query($sql);
$location = db_fetch_object($result);