How does one access the uid on a usernode for use in a views block? I have a block I made in views that appears only on a user's usernode, however I can't make the view work on the usernode because the url resembles node/2606 and 2606 does not relate to the uid. Basically I guess I need a way to translate the usernode ID into the author's UID. Thanks.

Comments

nigels’s picture

I'm having trouble with this too.

I want to get the node -> uid so I can add it to the views argument handling code.
I want to use this to display a block of images relating to the author of that node.

Im trying to use.........

Argument type
------------------
User: UID Authored or Commented

Argument code
------------------
$test = $node->uid
$args[0] = $test;
return $args;

But it doesn't work! Please help!!

Thanks

lunas’s picture

I finally got it working using this in the argument handling code:

$node=node_load(arg(1)); 
$args[0]=$node->uid;
nigels’s picture

Thanks Lunas I was scratching my head for days on this one!!!!!

It works!!!!!!!!

I also added a bit of extra code to prevent anything happening when you are viewing a page that isn't just a single node.


if ( ($type=='block') && is_numeric(arg(1)) ){
     $node=node_load(arg(1));
     $args[0]=$node->uid;
}
return $args;