1

I have a view on a node page. How do I get it to list all content that has the same author as the current node?

4

Are you using 6 or 7? In 6 you'll need to add an Argument; in 7 a contextual filter. Either way, it works pretty much the same.

  1. Create a block display.
  2. Add the fields you want (usually just the title for a simple list.)
  3. Add either an argument or contextual filter for the author uid.

Then under "Action to take if argument is not present", choose provide default value. For the default value, choose PHP Code, and add this code to the box:

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

Save your view; then clear all caches.

Note that the use of contextual filters renders the preview unusable; you'll need to actually add your block to a page to see it.

|improve this answer|||||
1

did you happen to reach a solution? This view settings works for me. It shows the content of the author of the current page.

enter image description here

|improve this answer|||||
  • This seems to work ok for me without the relationship - is the relationship necessary? – Juc1 Jul 31 '15 at 23:30
0

Can't you just add a filter and set the author id (uid) to whoever the page belongs to?

|improve this answer|||||
  • 1
    this wouldnt work because I want the author of the "current page" I would need to create a filter and pass in the author for every page – frazras Jul 9 '12 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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