I have a view block. It takes an argument to filter the content. The argument is the nid of a content profile. I then use a relationship to get the uid of the content profile. This uid means I only returns nodes related to the user of the content profile.

I wish to display this block on the users content profile page. So there would be a block listing nodes from the same user on there content profile. I am displaying the block using context.

What is the best way to get the filtering to occur. I currently am passing an argument which gets the nid of the content profile from the url. I have been told that I can do this by using spaces and contexts and not my custom php. How would you do this>

1 Answer 1


Add an argument of type Node[nid] to your views

Configure Action to take if argument is not present for Provide default argument as PHP Code

Add following code in the text area

  $node = node_load((int)arg(1));
  return $node->uid;
  • You can just put "retrieve the argument from URL if not present", it's not necessary to put php code.
    – tostinni
    Jun 15, 2011 at 18:31
  • 1
    We can get nid from url but not uid of that node Jun 15, 2011 at 18:40
  • Sure I miss read it ;)
    – tostinni
    Jun 15, 2011 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.