Example: My Recent Posts Block
This example creates a block that, once enabled, will display a list of recent posts by the user profile who's profile you are currently viewing.
Add a view
Goto: http://example.com/admin/build/views/add
Then enter the following values.
Basic Information
Name: user_posts
Block
Check Provide Block.
View Type: List View
Title: My Recent Posts
Nodes per Block: 10
Fields
Add Field: Node: Title
Arguments
Add Argument: User: UID is Author
Argument Handling Code
Argument Code: But don't include the <?php ?> tags. This is the working and tested Drupal 5.1 code, but a previous comment makes me believe that replacing $type with $view['type'] should cause the code to work with older versions.
<?php
$args;
if (
$type == 'block' &&
arg(0) == 'user' &&
is_numeric(arg(1))
) {
$args[0] = arg(1); // (user/# == arg(0)/arg(1))
}
return $args; // Remember to return $args
?>Filters
Add Filter: Node: Published
Sort Criteria
Add criteria: Node: Created Time with Order=Descending
Save
Enable the block you just created
If you've posted content, view your user page
