Hi, I've been playing around with the views module, multiblock and views api to try and get users to see the author of a node's other nodes in a block. eg if i view user/1's profile I would be presented with a block of that users stories.

Can someone point me in the right direction?

thanks

D

Comments

WorldFallz’s picture

You can do this with the views module. Blocks require php code in order to properly use arguments. Make a block view with the format and/or fields you wish, add an argument of "User: uid", then select "Provide default argument" and "PHP Code", and paste this into the code box:

if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = (int)arg(1);
  $node = node_load($nid);
  return $node->uid;
}
else {
  return FALSE;
}

This is untested-- but should be close.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

nevets’s picture

The key is you need an argument on "User: uid". For a block view make sure "Action to take if argument is not present:" is set to "Provide default argument" and "Default argument type:" to "User ID from URL". This will make a view that when visiting a page of the form user/{uid} lists all content authored by that user. You can set style add filters etc as needed.

dhaven’s picture

Thank you both. I have found the argument 'UID is Author' in views but it still shows nodes from all users. Using argument api I have added 'user: UID is Author' but still no joy.

Where is the 'default argument' option? in views? or where is "Action to take if argument is not present:" is set to "Provide default argument"?

thanks
D

nevets’s picture

Take a look at the tracker view it uses "User: uid" not "Uid is Author". When you add the argument "User: uid" (or edit) the add/edit section will have 'Action to take if argument is not present'.

dhaven’s picture

thanks to you both, works well! now i need to show the relevant author in the heading its not %user is it?