description
This snippet will display the thumbnail images of the most N most recently submitted images by the user. You can also optionally limit the images selected based on taxonomy term id's (see snippet for details)
instructions
- In a text editor paste the following snippet into your user_profile.tpl.php file
(For instructions on how to get started with your own custom user profile layout click through to the Customising the user profile layout handbook page.) - Upload your edited user_profile.tpl.php to your active theme folder
// Display N most recent thumbnails of images submitted by the user
// Each thumbnail is linked back to it's image node
// Can optional limit the photos shown by specififying one or taxonomy term id's
// The number of thumbnail images to show
$nlimit = 3;
$taxo_id = array();
// Add one line for each taxonomy term id you want to limit the thumbnails to
// As an example, the following two lines would select images associated with taxonomy terms 36 OR 37
// $taxo_id[] = 36;
// $taxo_id[] = 37;
// Note, if not taxonomy term ids are specified, the selection is from all the user submitted images
$userid=$user->uid;
if ( count($taxo_id) > 0 ) {
// Limit images based on taxonomy term id's
$taxo_str = implode(',', $taxo_id);
$sql = "SELECT n.created, n.title, n.nid, n.changed FROM node n INNER JOIN term_node ON n.nid = term_node.nid AND term_node.tid IN ($taxo_str) WHERE n.type = 'image' AND n.uid = $userid AND n.status = 1 ORDER BY n.changed DESC";
}
else {
$sql = "SELECT n.created, n.title, n.nid, n.changed FROM node n WHERE n.type = 'image' AND n.uid = $userid AND n.status = 1 ORDER BY n.changed DESC";
}
$result = db_query_range($sql, 0, $nlimit);
$output = '';
while ( $info = db_fetch_object($result) ) {
$node = node_load(array('nid' => $info->nid));
$img_tag = image_display($node, 'thumbnail');
$link = 'node/' . $node->nid;
$output .= l($img_tag, $link, array(), NULL, NULL, FALSE, TRUE);
}
print $output;
?>
No comments:
Post a Comment