I can't figure out how to set up a block view for this in Drupal 6:
Users submit a picture. If it is approved, I upload it to the site.
There is a node that shows the details of the picture and the author information. I wan开发者_StackOverflow中文版t to have a block that says, MORE BY THIS AUTHOR. This block would list more images that this author has submitted. How can I do this?
The URL is: mysite/content/name-of-image so I don't know how to create a view that shows all the images by this author since the user name is not in the URL. Can someone tell me how to do this?
Thank you.
- Add a user:uid argument to the view.
- choose "provide deafult argument" option for this argument.
- choose "php code" as default argument type.
enter following php code:
if (arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); $uid = $node->uid; } return $uid;
in your case you want the uid from a cck field of the node, so the php code should be this:
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
//if the field contains a user id
$uid = $node->field_authorid[0][value];
//if the field contains a username
$user = user_load(array('name' => check_plain($node->field_authorname[0][value])));
$uid = $user->uid;
}
return $uid;
Now you'll have the author user id from the node in url. Now you can add fields to the view from nodes created by this author.
NOTE: the view preview won't show any results, so you'll have to save this view and test it outside the views builder.
精彩评论