Community & Support

Using Views to show block with user's recent content. I'm stuck!

I want to show a block with viewed user's (not viewing user's) recent content.

so on user/1, i want to show UID 1's last 10 blog entries, video pages, forum threads, etc
and on user/2, I want to show UID 2's last 10 blog entries, etc, etc.

In views, there are filters for "Author is current user" which is not any use as I would get the same blocks showing on user/1, user/2, user/3 - it would always be the viewing user.

so then I dabbled a little with arguments, trying to use the UID /1, /2, /3 values. I set the argument to be "UID is Author" and it works in the page view, but not in the block. So I set the page URL to be "myrecentcontent" and going to /myrecentcontent/1 and then myrecentcontent/2 showed me different content, but the block isn't even showing up at all on the user/1 and user/2 pages. When I take away the argument from the View, the block reappears but showing ALL recent content.

so, does anyone know how to use the "UID is Author" argument for a block?

Comments

You are almost there, set it

You are almost there, set it up the way you had it working for a page view, the problem is block views do not get arguments, so for your view under "Arguments", "Argument Handling Code" add

$args = arrray();
if ( arg(0) == 'user' && is_numeric(arg(1)) ) {
  $args[] = arg(1);
}

return $args;

great, that did the trick. I

great, that did the trick. I just wanted to correct a typo on the first line in case others copy your code:

$args = array();
if ( arg(0) == 'user' && is_numeric(arg(1)) ) {
  $args[] = arg(1);
}

return $args;
nobody click here