Thank you Dries Buytaert and all of Drupal.org developers and users for making a very wonderful CMS

The proliferation and popularity of MySpace and Friendster and many other Social Networking sites are (IMHO) due to `user centric' customizable profiles and `friends' or `connections'

MySpace is actually a poor system based on CFM, if somebody said `I have the MySpace source code', forget it, you would rather have LiveJournal source code based on BML

The Drupal.org book section has almost complete (but not updated for Drupal 4.7.x and 5.x) guide on `custom user profile' and `how to make user profile customizable by the user'

Search for user_profile.tpl.php (cause I dont remember the title and link)

I am pasting here my user_profile.tpl.php AND template.php for anybody interested to be used for Drupal 4.7.x. Note that `view buddy list' is a link to buddylist/user instead of displaying a list of buddies, cause I dont know the right PHP code and the last time I got error for undefined format_name

Also note that I am using `foliage' theme style.css and I think `foliage' is flexible and good to begin learning how to customize your CSS

<style type="text/css"><?php print $user->profile_css ?></style>
<?php if($user->picture): ?>
<div class="picture">
<img align="right" src="http://myperkasa.com/<?php print $user->picture ?>">
</div>
<?php endif; ?>
<div id="perkasa_profile">
<div class="fields">Jenis kecacatan fizikal: <a href="http://myperkasa.com/profile/profile_jenis/<?php print $user->profile_jenis ?>"> <?php print $user->profile_jenis ?> </a> </div><p>
<div class="fields">Bidang: <?php print $user->profile_bidang ?></div><p>
<div class="fields">Maklumat diri atau organisasi: <?php print $user->profile_maklumat ?></div><p>
<div class="fields">Mesej: <?php print $user->profile_mesej ?></div><p>
<div class="fields">Interaksi melalui internet dan telefon: <?php print $user->profile_online ?></div><p>
<div class="fields">Sumbangan: <?php print $user->profile_sumbangan ?></div><p>
<div class="fields">URL: <a href="<?php print $user->profile_urlahli ?>"> <?php print $user->profile_urlahli ?> </a> </div><p>
</div>

<?php
 
  if ($user->uid != $account->uid && user_access('administer users')) {
  print check_plain($user->profile_sulit);
  }

?>
<p>

<div class="fields">
<p><?php  print t('Poin:').db_result(db_query('SELECT points FROM {userpoints} WHERE uid = %d', $user->uid));?></p>
</div>

<?php
 
  if ($user->uid != $account->uid && user_access('access private messages')) {
  print "<a target=\"_blank\" href=\"http://myperkasa.com/privatemsg/msgto/".$user->uid."\">Hantar mesej peribadi untuk " .$user->name. " </a>";
  }

?>
<p>


<?php
 
  if ($user->uid != $account->uid && user_access('access user guestbook')) {
  print "<a target=\"_blank\" href=\"http://myperkasa.com/guestbook/".$user->uid."\">Isikan buku tamu " .$user->name. "</a>";
  }

?>
<p>


<?php
 
  if ($user->uid != $account->uid && user_access('view buddy lists')) {
  print "<a target=\"_blank\" href=\"http://myperkasa.com/buddylist/".$user->uid."\">Lihat senarai rakan ahli " .$user->name. " </a>";
  }

?>
<p>


<?php
 
if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { 
  print "<a target=\"_blank\" href=\"http://myperkasa.com/buddy/delete/".$user->uid."\">Keluarkan " .$user->name. " dari senarai Rakan anda</a>";
  } 
else {
  if ($user->uid != $account->uid && user_access('maintain buddy list')) {
  print "<a target=\"_blank\" href=\"http://myperkasa.com/buddy/add/".$user->uid."\">Masukkan " .$user->name. " ke senarai Rakan anda</a>";
  }
}
?>
<p>




<?php
print "<div class=\"fields\">";
print "Status ";
$time_period = variable_get('user_block_seconds_online', 2700);
$uid = arg(1); // get the current userid that is being viewed.
$users = db_query("SELECT uid, name, access FROM {users} WHERE access >= %d AND uid = $uid", time() - $time_period);
          $total_users = db_num_rows($users);

          if ($total_users == 1) {
            $output = t(' ::  Sedang online');
          }
          else {
            $output = t(' ::  Keluar - offline');     
          }

              print $output;
                      print "</div>";
?>

<div class="fields">
<p>Terbaru oleh ahli ini</p>
<?php
  $uid = arg(1);
  $nlimit = 15;
  $result = db_query("SELECT n.created, n.title, n.nid, n.changed
  FROM node n
  WHERE n.uid = $uid
  AND n.status = 1
  ORDER BY n.changed
  DESC LIMIT $nlimit");
  $output4 .= "<div class=\"item-list\"><ul>\n";
  $output4 .= node_title_list($result);
  $output4 .= "</ul></div>";
  print $output4;
  ?>
</div>


<div class="gambar">
<p>Gambar oleh ahli ini</p>
<?php
// 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 = 20;
$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;
?>
</div>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result1)) {$output2 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output2; ?>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result2 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'story' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result2)) {$output3 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output3; ?>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result3 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'forum' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result3)) {$output5 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output5; ?>

Comments

Muslim guy’s picture

Sorry if non English texts are confusing you ;)

I could not edit the above entry

BTW, all about user_profile custom template

http://drupal.org/search/node/user_profile.tpl.php

http://drupal.org/search/node/user_profile.tpl.php+type%3Abook (Search in Books only)

*Thank you so much Dublin Drupaller for the guide, I took them and put it in usable form for non-programmers non-developers among us :)

Customising the user profile layout
http://drupal.org/node/35728

here's the template.php

<?php
/**
* Catch the theme_profile_profile function, and redirect through the template api
*/
function phptemplate_user_profile($user, $fields = array()) {
  // Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
  /* potential need for other code to extract field info */
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }
function phptemplate_search_theme_form($form) {
  return _phptemplate_callback('search_theme_form', array('form' => $form));
}
?>

One last thing, to see the stuff at work, see

[Link removed because it is no longer valid]

*Note also the top header `Login/Register' and large Search button which was taken from `Internet-service' theme

praveen-sl’s picture

hey,

Hey this really good. and after practicing these basics you can get design much more rich looking user profile pages. but as a point to mention i prefer performing all SQL queries in modules as blocks and then you can get that content using module_invoke() . this is known as a best practice in large web application development. anyway comment more on your code because as it is posted to non-technical people.

--
Praveen Gunasekara

Muslim guy’s picture

This is how I contribute back in a humble way to Drupal community and enthusiasts :)

As of now, I have added div id AND also the browsable `freeform list' - the result is displayed as a list

The original guide in the book is tricky to follow, but credit is for the developer

I was also thinking WHAT IF the `image thumbnails' be displayed in a block instead of inside the userprofile, but no success (tested using XAMPP and PHP version is not updated)

When I tried the `enlist buddylist' in a block, the site crashed and it wont recover, so WARNING: dont use that `buddylist' in a block [ error undefined function format_name thingy ]

To add browsable freeform list, add this to user_profile.tpl.php: (like Xing.com)

<div id="freeformlist">
<?php $fieldname = 'profile_bidang'; ?>
<?php if($user->$fieldname != ""): ?>
<p><b>Interest or have to offer or looking for:</b></p>
<ul>
<?php
$temp_array = split("[\n,]", $user->$fieldname);
$count_total = count($temp_array);
for($counter=0; $counter<$count_total; $counter++):?>
<?php $link = each($temp_array) ?>
<li><a href="http://myperkasa.com/profile/<?php print $fieldname; ?>/<?php print preg_replace('[\s]', '+', trim($link[value])) ?>" title="Members in"><?php print $link[value] ?></a></li>
<?php endfor ?>
</ul>
</div>
<?php endif ?>
Muslim guy’s picture

Anybody can right click on the background image (using Firefox web browser) and save them - the green, purple, and the mosque (please do not misuse the mosque background picture as it is a holy site)

http://myperkasa.com/user/1

Muslim guy’s picture

http://drupal.org/node/34484

Thanks a lot for the simple code, just add this to your Drupal 4.7.x user_profile.tpl.php

<?php
  if(!$user->guestbook_status){  // guestbook_status seems to store 0 for enabled and 1 for disabled
     print module_invoke('guestbook', 'page', $user->uid);
  }
?>

For 5.1, I havent tested but additional module_exists thingy is present by the original code contributed

<?php
if (module_exists('guestbook')) {
  if(!$user->guestbook_status){  // guestbook_status seems to store 0 for enabled and 1 for disabled
     print module_invoke('guestbook', 'page', $user->uid);
  }
}
?>
emwu25’s picture

Sweet ! just what I needed !

---------------------------------------------------------------
Em Wu
Tungsten Rings

falenire’s picture

Hi,

I'm trying to build a social network like my space one, and I've tried to use your code above, but I'm getting the next error

Fatal error: Call to undefined function _phptemplate_callback() in /home/.../themes/garland/template.php on line 110

I'll be glad to know a way to handle this.

Thanks in advance. Oh, I forgot to mention that I'm very new with drupal, but I think it's awesome!!!

Thanks!!!!

Muslim guy’s picture

There was an error if using Garland and you need to delete the source code that produces that error, in template.php

*Fatal error: Call to undefined function _phptemplate_callback() in /home/.../themes/garland/template.php on line 110

But for sure user-profile.tpl.php can be used with Foliage, and Garland (try removing some codes in template.php) until you get

Muslim guy’s picture

Yes almost complete - I used the following snippet for Drupal 4.7.x and it works

Display a list of buddies snippet
http://drupal.org/node/36501

*If a buddy has no pic, then the name is displayed, if got pic, the pic is displayed, and the name text is also displayed

<div class="friends">
<div id="profileBuddylist">
<div class="picContainer">
<?php
if ( user_access('view buddy lists') || user_access('administer users') ) {
    // if thisuser has friends, show friends
    $output = '';
    $i = 0;
    $cnt = variable_get('buddylist_prof_buddies', 5);
    if ($buddies = buddylist_get_buddies($user->uid)) {
      foreach(array_keys($buddies) as $buddy) {
        $account = user_load(array('uid' => $buddy));
        $output .=theme('user_picture', $account);
                $listbuddies[] = $account;
        $i++;
        if ($i > $cnt) {
          break;
        }
      }
      $output .= '</div>'. theme('user_list', $listbuddies);
    if (count($buddies) > variable_get('buddylist_prof_buddies', 5)) {
              $output .= '<div class="more-link">' . l(t('more'), 'buddylist', array('title' => t('View more.'))) . '</div>';
            }
  
      print $output;
    }
}
?></div></div></div>

Add this to your style.css

#profileBuddylist img{float:left; margin-right:10px;}
.picContainer{width:745px; height:87px;}
#profileBuddylist li{float:left; width:100px;margin-right:10px;text-align: center;}
Muslim guy’s picture

Yes, at last, audio and playlist are also embeddable in user_profile

<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result7 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'audio_playlist' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result7)) {$output7 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output7; ?>

<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result3 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'audio' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result3)) {$output6 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output6; ?>

Muslim guy’s picture

To display the user's Last Logged In / Last Access:

Create a new block named `Last seen' and set to appear only in user*

*I'd recommend not to use this as some users feel the info invades their privacy. But for community sake and for organizational site, its good to use this so that we can judge whether a user is active or not, and if suddenly an active user suddenly stops accessing your site, what happens to him?

<?php
  //Last logged in
  global $user;
  if ($user->uid>0){
   $userid = arg(1);
   //$userid = '1';

   $u = user_load(array("uid" => $userid));

   $output9 .= '<TABLE BORDER="1" CELLPADDING="1"  CELLSPACING="3" WIDTH="100%"> <TR><TD BGCOLOR="#f5f4ff"><FONT SIZE=-1>';

   $output9 .= '<FONT SIZE=-2><B>Akses:<BR> <FONT SIZE=-2>';
   $output9 .= format_date($u->access,'short');

   $output9 .= "</TD></TR></TABLE><BR>";
   $output9 .= "</FONT></B><FONT SIZE=-1>"; 
   $output9 .= '<center>';

  $output9 .=  "</center>";
  print $output9;
  }
?>
lainel’s picture

This one has an error, I inserted this into the user_profile.tpl.php page and the user 1 account information shows up on all the user's profile. Is there a way to fix this?

hugeknot’s picture

Hello
I have the audio php snippet, but I wnat only a certain type of audio to appear, namely audio that is classes 'profile demo'. Is this possible? Do I need a node.tid tag?
Come together

Muslim guy’s picture

This snippet return the number of buddies that user has (not yours)

<?php
$uid = arg(1);
$buddies = db_fetch_object(db_query("SELECT COUNT(buddy) AS count FROM {buddylist} WHERE uid= %d AND received=0", $uid));
echo "This member has $buddies->count buddies";
?>
Muslim guy’s picture

You might want to have a customized index page and different profile presentation, so that the user is also able to enter an image inside the header at the top, as if the site is his own

Or you can just disable your site logo and let user enters a background image URL in the CSS for header

Sree’s picture

guys thanks for sharing such kool stuff .... few lines of explanation about the code may make it very usefull for non-techie ppl ....

-- Sree --
IRC Nick: sreeveturi

Muslim guy’s picture

Sree, here's an all-english custom user profile you can use. Notice that i use profile_a, profile_b, until profile_i and annotate the type of profile fields (plain text, HTML, select, freeform list). This is for Drupal 4.7.x so be careful for 5.2.

Guestbook is embedded.
User's last access is omitted since it will cause some problem to the outputs.
User's buddy count is right after the userpicture.
User's buddies+pictures are the last at the bottom.
User's audio and playlist are embeddable, so if you have Playlist, the user's podcasting/xspf flash player is displayed.

<style type="text/css"><?php print $user->profile_css ?></style>
<?php if($user->picture): ?>
<div class="picture">
<img align="right" src="<?php print $user->picture ?>">
</div>
<?php endif; ?>



<?php
$uid = arg(1);
$buddies = db_fetch_object(db_query("SELECT COUNT(buddy) AS count FROM {buddylist} WHERE uid= %d AND received=0", $uid));
echo "This member has $buddies->count buddies";
?>


<div id="custom_profiles">
<div class="fields">A select: <a href="?q=profile/profile_a/<?php print $user->profile_a ?>"> <?php print $user->profile_a ?> </a> </div><p>
<div class="fields">B URL : <a target="_blank" href="http://<?php print $user->profile_b ?>"> <?php print $user->profile_b ?> </a> </div><p>
<div class="fields">C text: <?php print check_plain($user->profile_c) ?></div><p>
<div class="fields">D date: <?php print check_plain($user->profile_d) ?></div><p>
<div class="fields">E select: <a href="?q=profile/profile_e/<?php print $user->profile_e ?>"> <?php print $user->profile_e ?> </a> </div><p>
<div class="fields">F select: <a href="?q=profile/profile_f/<?php print $user->profile_f ?>"> <?php print $user->profile_f ?> </a> </div><p>
<div class="fields">G select: <a href="?q=profile/profile_g/<?php print $user->profile_g ?>"> <?php print $user->profile_g ?> </a> </div><p>
<div class="fields">H text: <?php print check_plain($user->profile_h) ?></div><p>
<div class="fields">I information html: 

<?php print $user->profile_i ?></div><p>
</div>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result7 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'audio_playlist' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result7)) {$output7 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output7; ?>

<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result6 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'audio' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result6)) {$output6 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output6; ?>



<div id="freeform">
<?php $fieldname = 'profile_j'; ?>
<?php if($user->$fieldname != ""): ?>
<p><b>J freeform list:</b></p>
<ul>
<?php
$temp_array = split("[\n,]", $user->$fieldname);
$count_total = count($temp_array);
for($counter=0; $counter<$count_total; $counter++):?>
<?php $link = each($temp_array) ?>
<li><a href="http://localhost/SNS/?q=profile/<?php print $fieldname; ?>/<?php print preg_replace('[\s]', '+', trim($link[value])) ?>" title="Members selecting this"><?php print $link[value] ?></a></li>
<?php endfor ?>
</ul>
</div>
<?php endif ?>


<div id="interaction">
<?php
 
  if ($user->uid != $account->uid && user_access('administer users')) {
  print check_plain($user->profile_K);
  }

?>
<p>
<?php
 
  if ($user->uid != $account->uid && user_access('administer users')) {
  print check_plain($user->profile_L);
  }

?>
<p>

<?php
 
  if ($user->uid != $account->uid) {
  print "<a target=_blank href=\"?q=contact/".$user->uid."\">Contact " .$user->name. " with your user email</a>";
  }

?>
<p>



<?php
 
  if ($user->uid != $account->uid && user_access('access private messages')) {
  print "<a target=_blank href=\"?q=privatemsg/msgto/".$user->uid."\">Send " .$user->name. " a privatemsg</a>";
  }

?>
<p>


<?php
 
  if ($user->uid != $account->uid) {
  print "<a target=_blank href=\"?q=guestbook/".$user->uid."\">View " .$user->name. " user guestbook</a>";
  }

?>
<p>

<?php
 
  if ($user->uid != $account->uid && user_access('view buddy lists')) {
  print "<a target=_blank href=\"?q=buddylist/".$user->uid."\">View " .$user->name. " user buddylist</a>";
  }

?>
<p>


<?php
 
if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { 
  print "<a target=_blank href=\"?q=buddy/delete/".$user->uid."\">Remove " .$user->name. " from your buddylist</a>";
  } 
else {
  if ($user->uid != $account->uid && user_access('maintain buddy list')) {
  print "<a target=_blank href=\"?q=buddy/add/".$user->uid."\">Add " .$user->name. " to your buddylist</a>";
  }
}
?>
<p>
</div>

<div class="fields">
<p><?php  print t('Points:').db_result(db_query('SELECT points FROM {userpoints} WHERE uid = %d', $user->uid));?></p>
</div>


<?php
print "<div class=\"fields\">";
print "Online/Offline Status    ";
$time_period = variable_get('user_block_seconds_online', 2700);
$uid = arg(1); // get the current userid that is being viewed.
$users = db_query("SELECT uid, name, access FROM {users} WHERE access >= %d AND uid = $uid", time() - $time_period);
          $total_users = db_num_rows($users);

          if ($total_users == 1) {
            $output = t(' ::  This user is currently online');
          }
          else {
            $output = t(' ::  This user is currently offline');     
          }

              print $output;
                      print "</div>";
?>

<div id="guestbook">
<?php
	if(!$user->guestbook_status) {
	print module_invoke('guestbook','page','$user->uid');
	}
?>
</div>

<div id="recent">
<p>Recent Posts</p>
<?php
  $uid = arg(1);
  $nlimit = 15;
  $result = db_query("SELECT n.created, n.title, n.nid, n.changed
  FROM node n
  WHERE n.uid = $uid
  AND n.status = 1
  ORDER BY n.changed
  DESC LIMIT $nlimit");
  $output4 .= "<div class=\"item-list\"><ul>\n";
  $output4 .= node_title_list($result);
  $output4 .= "</ul></div>";
  print $output4;
  ?>
</div>

<div id="images">
<?php
// 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 = 20;
$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;    gantikan dengan   $userid = arg(1);  create a custom block and set it to only show up on user/*

$userid = arg(1);  

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;
?>
</div>

<?php $nlimit = 2; ?>
<?php $userid=$user->uid; ?>
<?php $result8 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'acidfree' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result8)) {$output8 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output8; ?>


<div id="published">
<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result1)) {$output2 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output2; ?>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result2 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'story' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result2)) {$output3 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output3; ?>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result3 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'forum' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result3)) {$output5 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output5; ?>

</div>


<div id="buddy">
<?php
if ( user_access('view buddy lists') || user_access('administer users') ) {
    // if thisuser has friends, show friends
    $output = '';
    $i = 0;
    $cnt = variable_get('buddylist_prof_buddies', 15);
    if ($buddies = buddylist_get_buddies($user->uid)) {
      foreach(array_keys($buddies) as $buddy) {
        $account = user_load(array('uid' => $buddy));
        $output .=theme('user_picture', $account);
                $listbuddies[] = $account;
        $i++;
        if ($i > $cnt) {
          break;
        }
      }
      $output .= '</div>'. theme('user_list', $listbuddies);
    if (count($buddies) > variable_get('buddylist_prof_buddies', 15)) {
              $output .= '<div class="more-link">' . l(t('view'), 'buddylist', array('title' => t('View more.'))) . '</div>';
            }
  
      print $output;
    }
}
?>
</div>

Muslim guy’s picture

#content {
color: #00aaff;
background-color: #ffffff;
background-image: url('http://anywhere.com/mybackround.jpg');
}
#custom_profiles {
color: #ff0000;
background-color: #00aaff;
background-image: url('http://anywhere.com/mylogo.jpg');
}
.block .title {
font-family: georgia,verdana,helvetica,arial,sans-serif;
color: #00ff00;
background-color: #006600;
}
a:link {
color: #006600;
}
#header {
color: #ff0000;
background-color: #00aaff;
background-image: url('http://anywhere.com/myanimatedgifbanner.gif');
}


Liliplanet’s picture

Hi Muslim Guy,

Thank you so much for your excellent input to the profile fields. In the code below, please how do I change it that it's only the title and not the title and teaser with date, etc.

<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result2 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'story' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result2)) {$output3 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output3; ?>

Look forward to your reply.
Lilian

Muslim guy’s picture

Lilian

this was all from http://drupal.org/node/35728 so u might want to check if Dublin Drupaller has updated the handbook (or personally contact him)

Yes, if u want to only display the Titles (minus teasers), use: http://drupal.org/node/38538 (Recent Posts)

<div class="fields">
<p>Recent Posts</p>
<?php
  $uid = arg(1);
  $nlimit = 5;             /*     Change this number to 10 15 or any you like  */
  $result = db_query("SELECT n.created, n.title, n.nid, n.changed
  FROM node n
  WHERE n.uid = %d
  AND n.status = 1
  ORDER BY n.changed
  DESC LIMIT $nlimit", $uid);
  $output3 .= "<div class=\"item-list\"><ul>\n";
  $output3 .= node_title_list($result);
  $output3 .= "</ul></div>";
  print $output3;
  ?>
</div>

But if u want to set your teaser (cut-off) shorter or none, u have to set your admin/content to display `none' and use this (excluding page, poll, forum).

You can just copy & paste the earlier entries just for blogs, audio, playlist, story, (just change the node type name so if you use CCK and have cck_myresume you can display it)

<?php $nlimit = 10; ?>                   /*     Change this number to 5 15 or any you like  */
<?php $userid=$user->uid; ?>
<?php $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.uid = $userid AND n.type != 'page' AND n.type != 'poll' AND n.type != 'forum' AND n.type != 'story' ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result1)) {$output2 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output2; ?> 

Example: if you have CCK_myresume:

<div id="published">
<?php $nlimit = 2; ?>
<?php $userid=$user->uid; ?>
<?php $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'cck_myresume' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result1)) {$output2 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output2; ?>
Liliplanet’s picture

Thank you Muslim Guy, I've posted on Dublin Druppalers post directly. Most appreciate your help.
Lilian

Muslim guy’s picture

Just another new addition - Chatroom can be embedded also, but i think you have to set up PATHAUTO so that a user's chatroom will be assigned something like userchatroom/userID so that you can call this user's chatroom node. You will see the chatroom, and the list of CHAT (Chatroom is a node, whereas a chat is a conversation using javascript; a chatroom can contain many chats).

So you will see Chatroom, and under it is Chats, last messages, by whom, time and date

You might want to limit 1 chatroom per user (using usernodes.module)

Whereas for MYSITE, i found that by using module_invoke, the entire Mysite view is embedded in the user profile (you will see page inside page)

I am dumb at PHP and APIs, so I had to just create a link `View this user's Feeds'

I tried using Javascript that opens up a new window to the user's MySite, it works, but you might find its annoying because if the user doesnt customize her MySite, the new window will just be a blank page. And one new pop up window per user profile is irritating.

So the last thing i am still trying to do is to embed Mysite, i will contact the module developer to get his help

Jenzen-1’s picture

Hello,
i want to integrate a link to guestbook, like: "view recent guestbook entries"
How can i realize this?

following code (snippet user_profile.tpl.php) ist not correct for this topic:

if(!user->guestbook_status) {
print module_invoke('guestbook', 'page', $user->uid)
}

Thanks!

Muslim guy’s picture

To embed the guestbook (which means it is inside the profile, like MySpace comments or Facebook Wall)

<?php
  if(!$user->guestbook_status){  
     print module_invoke('guestbook', 'page', $user->uid);
  }
?>

Above is for Drupal 4.7.x

If you want only a link, then use

<?php

  if ($user->uid != $account->uid) {
  print "<a target=_blank href=\"?q=guestbook/".$user->uid."\">View " .$user->name. " user guestbook</a>";
  }

?>
Jenzen-1’s picture

Thanks for help!!
It works!!!

Greetings, Jenzen!

Jenzen-1’s picture

Hi Muslim guy,

  if ($user->uid != $account->uid) {
  print "<a target=_blank href=\"?q=guestbook/".$user->uid."\">View " .$user->name. " user guestbook</a>";
  }

this code produce a link to the my guestbook. I need the link to the guestbook of the user i visit.

I hope you have an answer!

Greetings!!

Muslim guy’s picture

Are u testing it on a localhost? Coz the localhost (with XAMPPLite) although enables the guestbook embedding and linking, will produce wacky results

Jenzen-1’s picture

Yes I´testing on a localhost. Thanks for your answer, i will test the guestbook online in a few days.

Jenzen-1’s picture

Hi Muslim guy,
if i click on the "guestbook-link" in the profile i visit --> the browser opens a new tab. Is it possible to open the visit guestbook in the same tab?

Greetings!

Muslim guy’s picture

Remove target = _blank

<?php
  if ($user->uid != $account->uid) {
  print "<a href=\"?q=guestbook/".$user->uid."\">View " .$user->name. " user guestbook</a>";
  }
?>

I am sure you are familiar with HTML codes eh? If you want to for example open in new small pop up window you can insert a javascript but thats another story :)

Jenzen-1’s picture

I am not familar with HTML, PHP... The last weeks were my first weeks with drupal, but it´s an amazing programm. It´s fine what I realized the last weeks. Thank you for your benefit!!

Muslim guy’s picture

Thanks to AgentTrickard

http://groups.drupal.org/mysite

Suggested this

<?php
  $uid = arg(1); // you can derive this however you like; it is the UID of the profile owner.
  $mysite = mysite_get($uid); // this will load the user's MySite settings, including the layout they use.
  $mycontent = mysite_page($uid, $pageview = FALSE); // this gets the data.
  $output = theme('mysite_'. $mysite->layout .'_layout', $mycontent); // this themes the data.
  print $output;
?>

I tried (my Drupal 4.7.x) but got no output whatsoever. Havent tried with 5.x

I also tried modyfing similar code for module_invode for the guestbook, replacing with mysite_page, or pageview = false, but doesnt work.

Muslim guy’s picture

<?php
  if ($user->uid != $account->uid && user_access('administer users')) {
	print module_invoke('address','page','$user->uid');
  }
?>

Only admin or self can see the address book (useful so that u don't have to open the address book in new window)

To use address book, u have to activate E-Commerce package - Store and Address

Note that E-Commerce modules for 4.7.x are really different approach different versions

I saw that the ecommerce-4.7.x-3.4.tar.gz - the country and state list are inside store.module

whereas the earlier versions put the country-state options in store_location.inc and there is instructional help on how to create your own country's list of states, so that when that country is selected, the list of states will appear

Muslim guy’s picture

<iframe src="http://anysite.com/" width="500" height="500" frameborder="0"></iframe>

Iframe can be used to display other sites in user profile, you can also insert this so that the user profile displays the user's URL

<?php print $user->profile_url ?> <p>
<iframe src="http://<?php print $user->profile_url ?>" width="500" height="500" frameborder="0"></iframe>
Muslim guy’s picture

About MySite: u can specify that the user's MySite is `full view' (no side blocks)

So u can use iframe to display the user's MySite (http://domain.com/mysite/ID) where ID is the userid

For chatroom, u can use iframe so that people can go straight into the user's chatroom and create chats or choose which chat to join. U have to use Pathauto to obtain http://domain.com/chatroom/ID

For user's URL, u can display the website directly, however some Friendster profiles are known to be `hijacking' the browser, and Myspace profiles are so laden with widgets and glitters that the browser will crash. Its up to you to use iframe, or just a link with target=_blank. I prefer iframe for user's URL just so that he/she stays longer in our site while having the ability to monitor his own site

Muslim guy’s picture

Users have asked `how do we make tabs so that we can separate the main user biodata from the less important user profile (like URL and node submissions, and that pesky iframe that displays external websites)

The answer is: VIRTUAL PAGINATION from http://dynamicdrive.com

You can see how we implemented it in user-profile.tpl.php (Save as .....)

http://almuslimin.net/JODOH/themes/MUFLIHUN/virtualpaginate.js

http://almuslimin.net/JODOH/themes/MUFLIHUN/user_profileVIRTUALPAGINATIO...

By virtual pagination, you get several pages and Tabs that users viewing the profile can click page 1, 2, 3, 4....

Our implementation has 4 pages, you can add more or less

*After seeing a Xoops expert video on User profile, we were motivated to do the pagination. We havent got time to modify the styling and color, but you can try yourself and paste it back here thank you

Muslim guy’s picture

For Drupal 5.3, this userprofile embeds almost all of the node types you want (Event, Blog, Forum, Story, Gallerix album, Acidfree album, Image, Chatroom).

A custom node type `publicprofile' which is a CCK NodeProfile with a Picture, and short user intro, is embedded.

NodeProfile Address - CCK : if you use it, then it will show up.

User's poll is embedded - so you can use it for `profile voting'. Its up to the user to create poll question.

Guestbook is embedded, but it still redirect to the guestbook and doesnt stay in the profile (user has to return back to view the entire profile, but the guestbook is updated).

Gallery2 - user's album (random) is embedded.
*****If you don't use Gallery2, remove the gallery2 snippet as this will cause error or system crash.*****

A link back to the top of profile is present, to ease navigation.

User's biodata:
Date is embedded, if entered correctly, the user's age is calculated. The date field can also be used for future , but the `countdown' php snippet is not included.

Buddylist - at the bottom is the buddylist + pictures. At the top is `count buddies' but it is for 4.7.x. I will search for 5.x.

So you can actually combine the two methods of custom user profile + NodeProfile, the power of Drupal, and the web browser capabilities and all Web 2.0 widgets you want.

Possible additions but not included (search Google or contact us to obtain the scripts and how to insert correctly):

1. Virtualpagination - DynamicDrive - to divide the user profile into more than 1 page, Tabs

2. Iframe - to display the user's URL

3. Online presence - YM, Skype, etc

4. User's announcement in a drop-in box, or pop-up window

5. InputDraw - sketch or free-hand drawing on user's avatar (like Facebook's) or user's picture

6. User's AJAX / Lightbox gallery

7. User's links to open as AJAX pop up window

8. E-commerce integration - user's address, user's orders, and status

9. User's MySite RSS feed

Working on:
How to send a quick `nudge' or `poke' that will output as `pop-up window' to the user if he/she is online
(Private message shows up only if the user refresh the browser)
(Chatbox - inviting an online user will output as pop-up)

Embedding PHP-FreeChat for the user's node. Chatroom (different module) can be embedded, but the module itself IMHO is not quite usable

http://muflihun.com/user/1

Muslim guy’s picture

<style type="text/css"><?php print $user->profile_css ?></style>
<?php if($user->picture): ?>
<div class="picture">
<a name="atas"></a>
<img align="right" src="http://muflihun.com/<?php print $user->picture ?>">
</div>
<?php endif; ?>

<?php
print "<div class=\"fields\">";
print "Status ";
$time_period = variable_get('user_block_seconds_online', 2700);
$uid = arg(1); // get the current userid that is being viewed.
$users = db_query("SELECT uid, name, access FROM {users} WHERE access >= %d AND uid = $uid", time() - $time_period);
          $total_users = db_num_rows($users);

          if ($total_users == 1) {
            $output = t(' ::  Online');
          }
          else {
            $output = t(' ::  Offline');     
          }

              print $output;
                      print "</div>";
?>

<?php
$uid = arg(1);
$buddies = db_fetch_object(db_query("SELECT COUNT(buddy) AS count FROM {buddylist} WHERE uid= %d AND received=0", $uid));
echo "$buddies->count buddies";
?>
<p>

<?php
if (module_exists('chatroom')) {
     print module_invoke('chatroom', 'page', $user->uid);
}
?>


      <?php
      // Grid block (4 random images in 2 columns from useralbum of the profile's owner)
      $params = array(
        'blocks' => implode('|', array_fill(0, 4, 'randomImage')),
        'itemId' => 'user:'. $user->uid
      );
      $block = gallery_get_block($params, 2);
      print $block['content'];
      ?>


<div id="pictures">
<marquee>
<?php
// 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 = 20;
$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;    replace with   $userid = arg(1);  
// If you want to put this in a block - create a custom block and set it to only show up on user/*

$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;
?>
</marquee>
</div>


<?php $nlimit = 1; ?>
<?php $userid=$user->uid; ?>
<?php $result9 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'publicprofile' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result9)) {$output9 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output9; ?>


<?php $nlimit = 3; ?>
<?php $userid=$user->uid; ?>
<?php $result8 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'event' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result8)) {$output8 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output8; ?>

<?php $nlimit = 5; ?>
<?php $userid=$user->uid; ?>
<?php $result7 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'album' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result7)) {$output7 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output7; ?>

<?php $nlimit = 5; ?>
<?php $userid=$user->uid; ?>
<?php $result6 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'audio' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result6)) {$output6 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output6; ?>

<?php $nlimit = 1; ?>
<?php $userid=$user->uid; ?>
<?php $result5 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'poll' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result5)) {$output5 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output5; ?>

<?php $nlimit = 3; ?>
<?php $userid=$user->uid; ?>
<?php $result4 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'acidfree' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result4)) {$output4 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output4; ?>


<?php $nlimit = 3; ?>
<?php $userid=$user->uid; ?>
<?php $result10 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'chatroom' AND n.status = 1 AND n.uid = $userid ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result10)) {$output10 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output10; ?>


<div id="muflihun_profile">
<div class="birthday">
Important / Birth date: <?php print $user->profile_date['day']."/".$user->profile_date['month']."/".$user->profile_date['year'];?><br>
<?php
    $year_diff = date("Y") - ($user->profile_lahir{year});
    $month_diff = date("m") - ($user->profile_lahir{month});
    $day_diff = date("d") - ($user->profile_lahir{day});
    if ($day_diff < 0 && $month_diff < 0)
      $year_diff--;?>
<p>Age: <?php print $year_diff; ?> </p>
</div>
<div class="fields">Business or Professional Field or Specialty: <a href="http://muflihun.com/profile/profile_userfield/<?php print $user->profile_userfield ?>"> <?php print $user->profile_userfield ?> </a> </div><p>
<div class="fields">Description: <?php print $user->profile_describe ?></div><p>
<div class="fields">Location: <a href="http://muflihun.com/profile/profile_location/<?php print $user->profile_location ?>"> <?php print $user->profile_location ?> </a> </div><p>
<div class="fields">Country: <a href="http://muflihun.com/profile/profile_country/<?php print $user->profile_country ?>"> <?php print $user->profile_country ?> </a> </div><p>
<div class="fields">Free e-mails: <?php print $user->profile_freeemail ?></div><p>
<div class="fields">Message to all: <?php print $user->profile_messageto ?></div><p>
<div class="fields">Online: <?php print $user->profile_online ?></div><p>
<div class="fields">Video: <?php print $user->profile_video ?></div><p>
<div class="fields">URL: <a target="_blank" href="<?php print $user->profile_url ?>"> <?php print $user->profile_url ?> </a> </div><p>
</div>

<?php
  if ($user->uid != $account->uid && user_access('administer users')) {
  print check_plain($user->profile_confidential);
  }
?>
<p>



<div class="fields">Usage: <a href="http://muflihun.com/profile/profile_usage/<?php print $user->profile_usage ?>"> <?php print $user->profile_usage ?> </a> </div><p>
<div class="fields">Languages: <a href="http://muflihun.com/profile/profile_language/<?php print $user->profile_language ?>"> <?php print $user->profile_language ?> </a> </div><p>


<div id="interaction">

<?php
  if ($user->uid != $account->uid) {
  print "<a target=\"_blank\" href=\"http://muflihun.com/contact/".$user->uid."\">Contact " .$user->name. " using your registered email</a>";
  }
?>

<p>
<?php
  if ($user->uid != $account->uid && user_access('access private messages')) {
  print "<a target=\"_blank\" href=\"http://muflihun.com/privatemsg/msgto/".$user->uid."\">Send private message to " .$user->name. " </a>";
  }
?>
<p>


<?php
  if ($user->uid != $account->uid && user_access('access user guestbook')) {
  print "<a target=\"_blank\" href=\"http://muflihun.com/guestbook/".$user->uid."\">View the guestbook of " .$user->name. "</a>";
  }
?>
<p>

<?php
  print "<a target=\"_blank\" href=\"http://muflihun.com/mysite/".$user->uid."\">View RSS feeds of " .$user->name. "</a>";
?>
<p>

<?php
  if ($user->uid != $account->uid && user_access('view buddy lists')) {
  print "<a target=\"_blank\" href=\"http://muflihun.com/buddylist/".$user->uid."\">View buddylist of " .$user->name. " </a>";
  }
?>
<p>

<?php
if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { 
  print "<a target=\"_blank\" href=\"http://muflihun.com/buddy/delete/".$user->uid."\">Remove " .$user->name. " from your buddylist</a>";
  } 
else {
  if ($user->uid != $account->uid && user_access('maintain buddy list')) {
  print "<a target=\"_blank\" href=\"http://muflihun.com/buddy/add/".$user->uid."\">Add " .$user->name. " to your buddylist</a>";
  }
}
?>
<p>
</div>

<?php
if (module_exists('guestbook')) {
  if(!$user->guestbook_status){  
     print module_invoke('guestbook', 'page', $user->uid);
  }
}
?>


<div id="latest">
<p>Latest</p>
<?php
  $uid = arg(1);
  $nlimit = 15;
  $result = db_query("SELECT n.created, n.title, n.nid, n.changed
  FROM node n
  WHERE n.uid = $uid
  AND n.status = 1
  ORDER BY n.changed
  DESC LIMIT $nlimit");
  $output4 .= "<div class=\"item-list\"><ul>\n";
  $output4 .= node_title_list($result);
  $output4 .= "</ul></div>";
  print $output4;
  ?>
</div>



<div id="shareinterest">
<?php $fieldname = 'profile_offer'; ?>
<?php if($user->$fieldname != ""): ?>
<p><b>Have to offer:</b></p>
<ul>
<?php
$temp_array = split("[\n,]", $user->$fieldname);
$count_total = count($temp_array);
for($counter=0; $counter<$count_total; $counter++):?>
<?php $link = each($temp_array) ?>
<li><a href="http://muflihun.com/profile/<?php print $fieldname; ?>/<?php print preg_replace('[\s]', '+', trim($link[value])) ?>" title="Members"><?php print $link[value] ?></a></li>
<?php endfor ?>
</ul> 
<?php $fieldname1 = 'profile_Locations'; ?>
<p><b>Looking for:</b></p>
<ul>
<?php
$temp_array = split("[\n,]", $user->$fieldname1);
$count_total = count($temp_array);
for($counter=0; $counter<$count_total; $counter++):?>
<?php $link = each($temp_array) ?>
<li><a href="http://muflihun.com/profile/<?php print $fieldname1; ?>/<?php print preg_replace('[\s]', '+', trim($link[value])) ?>" title="Members"><?php print $link[value] ?></a></li>
<?php endfor ?>
</ul> 
<?php $fieldname2 = 'profile_interests'; ?>
<p><b>Interests:</b></p>
<ul>
<?php
$temp_array = split("[\n,]", $user->$fieldname2);
$count_total = count($temp_array);
for($counter=0; $counter<$count_total; $counter++):?>
<?php $link = each($temp_array) ?>
<li><a href="http://muflihun.com/profile/<?php print $fieldname2; ?>/<?php print preg_replace('[\s]', '+', trim($link[value])) ?>" title="Members"><?php print $link[value] ?></a></li>
<?php endfor ?>
</ul> 
</ul>
</div>
<?php endif ?>



<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result1)) {$output1 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output1; ?>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result2 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'story' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result2)) {$output2 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output2; ?>


<?php $nlimit = 10; ?>
<?php $userid=$user->uid; ?>
<?php $result3 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'forum' AND n.status = 1 AND n.uid = $userid ORDER BY n.created ASC"), variable_get('default_nodes_main', $nlimit)); ?>
<?php while ($node = db_fetch_object($result3)) {$output3 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
<?php print $output3; ?>



<div id="buddy">
<p>
IKHWAN LIST
<?php
if ( user_access('view buddy lists') || user_access('administer users') ) {
    // if thisuser has friends, show friends
    $output = '';
    $i = 0;
    $cnt = variable_get('buddylist_prof_buddies', 15);
    if ($buddies = buddylist_get_buddies($user->uid)) {
      foreach(array_keys($buddies) as $buddy) {
        $account = user_load(array('uid' => $buddy));
        $output .=theme('user_picture', $account);
                $listbuddies[] = $account;
        $i++;
        if ($i > $cnt) {
          break;
        }
      }
      $output .= '</div>'. theme('user_list', $listbuddies);
    if (count($buddies) > variable_get('buddylist_prof_buddies', 15)) {
              $output .= '<div class="more-link">' . l(t('view'), 'buddylist', array('title' => t('View more.'))) . '</div>';
            }
  
      print $output;
    }
}
?>
</div>



<a href="#atas">Back to top of profile</a>

Muslim guy’s picture

Chatroom is embedded

If you want to display Chatroom, the php snippet is above the gallery2 snippet

Included: groupmainpage (organic group CCK), acidfree, chatroom, poll, Gallerix

Embedded: Gallery2, Guestbook

http://muflihun.com/themes/MUFLIHUN/user_profileMUFLIHUN.tpl.php.txt

pierrelord’s picture

Hi,
Thanks for all your input and snippets help on user_profile.tpl. This is a great help.
I am trying to do something which seems innocuous, but I can't seem to figure this out...

I am trying to display a user's latest comments in user_profile..

Something like:

UserX's latest (n) comments:
Comment title (linked)
on "Node-commented-on" (linked)
on "Date-comment-created"

any ideas on this?
Thanks in advance.
pl

Muslim guy’s picture

We just realized a wrong `contact' link

Instead of /contact/ID (thus sending to admin emails)

It should be
/user/ID/contact

<?php
  if ($user->uid != $account->uid) {
  print "<a target=\"_blank\" href=\"http://ourdomain.com/user/".$user->uid."/contact\">Contact " .$user->name. " - using your email</a>";
  }
?>

Anyway the default user profile tab already displays `Contact' tab below the user name (but some users were not aware of tabs)

mokargas’s picture

How can I insert an ad.module block in user_profile.tpl.php?

mike.hobo’s picture

this can be done by using the inline regions thing on user_profile.tpl.php and then just going to your blocks page and activating to the custom region you define.

mokargas’s picture

Mike, I've tried this to no avail. It just appears blank.

I made a region in my template.php called 'ad', placed the ad module block in the ad region, and called print $ad in user_profile.tpl.php and it still appears empty.

mike.hobo’s picture

So your template.php should look like this if it doesn't...

<?php
function TEMPLATE_regions() {
  return array(
    'sidebar_left' => t('left sidebar'),
    'sidebar_right' => t('right sidebar'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer'),
    'ad' => t('ad'),
  );
}


/**
* Catch the theme_user_profile function, and redirect through the template api
*/
function phptemplate_user_profile($user, $fields = array()) {
  // Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
  /* potential need for other code to extract field info */
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }
?>

the second part allows regions to be in the user_profile.tpl.php

then after that, you should put this into your user_profile.tpl.php file where you want it.. then try.

<?php
print $ad
?> 
mokargas’s picture

Exactly what I have. Not sure what's going on :/

mike.hobo’s picture

maybe it involves the ad module

mokargas’s picture

All ads are active, permissions are set to show for all user types, and that all works in every page but user_profile.tpl.php

mike.hobo’s picture

I think I know your problem.. you need to add this into the template.php

<?php
function _phptemplate_variables($hook, $variables) {
  if ($hook == 'user_profile') {
    foreach (array('ad') as $region) {
      $variables[$region] = theme('blocks', $region);
    }
  }
  return $variables;
}
?>
netentropy’s picture

how hard would it be to put each of these snippets in tabs like Joomla's community builder

here is an example

http://www.shareyourexpertise.com/wvuauthor/

Muslim guy’s picture

We have seen profiles with tabs (with Xoops), and we have implemented DynamicDrive's `virtual pagination' succesfully

You can download Dynamic Drive's scripts and implement in user-profile.tpl.php easily, but be aware that some browsers like IE will tend to give problems, and webhosting/server tends to slow down if excessive Javascript is employed

*The Joomla profile you show does use Javascript

72dpi’s picture

Very simple.

You should use tabs that already work with Jquery:
I would suggest using Jquerys already awesome power, and simply add the one found here:
http://stilbuero.de/jquery/tabs_3/

Hope that helps!

netentropy’s picture

could you help me figure out how to implement this for recent blog posts, buddy lists, and a profile field tab

pribeh’s picture

I don't get why the add/remove links still display to the (logged in) user when it is viewing its own profile...

I'm totally indebted to you, Muslim Guy, for these great user.profile snippets. But I don't know if this has to do with the fact that I'm using a panel (of 'panels version 2') to incorporate my custom profile, but I can't find a way to get the following snippet to hide (NOT display) said links to the (logged-in) user who is viewing his/her own profile. Is there some part of the php that I'm missing? I've placed the following snippet into a custom profile with very little other info, and I then use blocks/views to display the rest of the field data, user content, etc. This is the only way I've been able to get add/remove buddy snippets to work in my panel.profile.


  if ($user->uid != $account->uid && user_access('administer users')) {
  print check_plain($user->profile_K);
  }


  if ($user->uid != $account->uid && user_access('administer users')) {
  print check_plain($user->profile_L);
  }


  if ($user->uid != $account->uid) {
  print "<a target=_blank href=\"?q=contact/".$user->uid."\">Contact " .$user->name. " with your user email</a>";
  }


  if ($user->uid != $account->uid && user_access('access private messages')) {
  print "<a target=_blank href=\"?q=privatemsg/msgto/".$user->uid."\">Send " .$user->name. " a privatemsg</a>";
  }


  if ($user->uid != $account->uid && user_access('view buddy lists')) {
  print "<a target=_blank href=\"?q=buddylist/".$user->uid."\">View " .$user->name. " user buddylist</a>";
  }


if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) {
  print "<a target=_blank href=\"?q=buddy/delete/".$user->uid."\">Remove " .$user->name. " from your buddylist</a>";
  }
else {
  if ($user->uid != $account->uid && user_access('maintain buddy list')) {
  print "<a target=_blank href=\"?q=buddy/add/".$user->uid."\">Add " .$user->name. " to your buddylist</a>";
  }
}
lfhubcom’s picture

I have 6.1 and everything i want is in 5x so should i downgrade and upgrade when it all becomes available if ever?

hedac’s picture

look at this tutorial
http://shellmultimedia.com/misc/user-profiles

version 2 tutorial is nice

catbyte’s picture

Yes, thats right. We build our new community with this tutorial! It's very easy to build. Nice view.

http://rc-fahrerlager.de/

Greets Maik

Michelle’s picture

Just saw this thread. Thanks for the linking. :) I think it's great, though, that he's showing what can be done with the core profile module for those who don't want to use nodes.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

gonz’s picture

It appears Panels is still in Dev mode - have you noticed any hickups that would deem it not worthy for a production site?

mike.hobo’s picture

Hey, thank you so much for all these great snippets. I just wondering though, I am using Drupal 5 and using the Playlists. so I used the code you provided to embed it on the profile, and for some reason though, it says that the playlist file is undefined?? I don't get it at all.

pribeh’s picture

In regards to Mike's post. I added your code for the playlist to a 5.3 install and all it doesn't seem to display. I've gotten other snippets to display audio nodes but none to display a playlist of the displayed user's uploaded audio.

pribeh’s picture

edit: nevermind

Muslim guy’s picture

It seems that PLAYLIST.module is not upgraded to 5.x

See
http://drupal.org/project/playlist

Whilst i dont know really how to arrange individual audios to be in queue in XSPF player.

The newest AUDIO.module has the `attach' so that u can attach an audio to a node (page, story, blog, or custom node) so u can create almost a playlist

It seems that the user has to subscribe to the audio feed using his browser, or click on the `m3u' or `pls' and choose his desktop audio player (usually winamp, realplayer, or MPlayer); not very nice since listeners do have to install audio players. The bright side is that u save your bandwidth by not hosting that Flash playlist thingy

So u might want to create a custom node named `userplaylist' and enables audios to be attached

*On the other hand, try
Creating playlists (eg. xml files) on the fly
http://drupal.org/node/143656

mike.hobo’s picture

subscribing

OutCast’s picture

For everything yall have done on this page,, I have almost got my site ready
You can see it here
http://www.shadowsonline.com/shadow
That is going to my profile page..

One thing i really need help in I just can not seem to get it
I would like to have a copy and paste link on the profile pages that will give the members their
link all set up so they can copy it and then paste it on another site or forum.

this would be a big help to anyone that has done this or could show me thanks

netentropy’s picture

can you do the same thing with my relationships modules as with the buddylist module

Muslim guy’s picture

I dont know whats the advantage of this module with regard to Buddylist which can be used together with Privatemsg and Profile Privacy Feature

I did used it but not beyond grouping and naming the groups

You might want to contact the developer himself to help you with the API (which portion of the codes can be pasted into the custom user profile)

Muslim guy’s picture

<div id="tcontent1" class="tabcontent">

    <textarea onClick="highlight(this);" cols="50" rows="5" id="code"><a target="_blank" href="http://mydomain.com/user/<?php print $user->uid ?>" title="Mydomain.com Members No. <?php print $user->uid ?> @ http://mydomain.com/">
<img border=0 src="http://mydomain.com/files/pictures/picture-<?php print $user->uid ?>.jpg" />
<img border=0 src="http://mydomain.com/files/pictures/picture-<?php print $user->uid ?>.gif" />
<img border=0 src="http://mydomain.com/files/pictures/picture-<?php print $user->uid ?>.png" />
<br>
<?php print $user->name ?><br>
Mydomain.com Members No. <?php print $user->uid ?> 
</a>
<p>
 <a href="http://mydomain.com/" target="_blank"><img src="http://mydomain.com/themes/mytheme/mybanner.jpg" border="0"></a></textarea>

</div>

<div id="tcontent2" class="tabcontent">
    <textarea onClick="highlight(this);" cols="50" rows="5" ><img border=0 src="http://mydomain.com/themes/mytheme/mybanner.jpg" /></textarea>

</div>


</div>

<div align="center">
  <script type="text/javascript">
//Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
initializetabcontent("maintab")
</script>


*Note - if the user uploaded several avatars of three types (jpg, gif, png) by default, Drupal system doesnt delete, so all three avatars are kept as pictures-userid.jpg/gif/png. So the user can display three avatars by this html.

*Note - this enables the user to mouse click and highlight the html, he still needs to Ctrl-C (copy to clipboard)

*If using path alias, for example http://mydomain.com/myname instead of user/ID, can anybody help how to output this as a print so people can see the URL

*This script is modified from Mashable.com `widgets for user profiles'

lias’s picture

Is that a module or custom css? Your profiles look a lot like myspace. Is the theme something each user can choose?

OutCast’s picture

Hey Guys sorry I been away so long ,
The answer to the themeable profiles are . A lot of looking at how myspace is coded ,
I used old fashion tables, I named each table, tr, td, and div, the same as myspace did theirs,
what that does is allow members to paste in myspace codes from popular sites in order to theme

Also we are going to make some custom themes for are members that work even better just for our site soon

Right now I have been completey redoing the site, profiles and all, so I will post back once done,

And If anyone would like it , I will more then happy share my codes so others can use it also

lainel’s picture

Do you mind showing an example code of the boxes? I am having trouble with this.
I've been fighting with it for the longest. If so, thanks

lainel’s picture

I was looking at your website and I have a few questions.And it looks great

1. How did you alignyour profile boxes across from each other.
2. How did you allow text in the profile to be changed
3. How did you allow users to change their profile url(Like myspace)?

Thanks

lainel’s picture

Try this code here.
It took me a while to find this code. Insert this into your user_profile.tpl.php page

With The Click Link

'); document.write(location.href); document.write(''); // -->

Without The Click Link

Muslim guy’s picture

Finally, after searching by Google, found a solution at

http://drupal.org/node/93981

By popboard http://drupal.org/user/86536 (thanks a lot)

You need to use Buddylist so that the user has the options to make his profile for `Friends only' or `Registered users'

You will need user-profile.tpl.php which is the full user profile viewable by friends, and private_profile.tpl.php, which is viewable by non-friends

Its up to you to put what into private_profile.tpl.php - but remember that the `Add to buddylist' snippet should be

Need also to replace your template.php with the one supplied by popboard.

I had error with process.php, so i just deleted some portion leaving only the important database update thingy

I dont know how to theme the process.php, it just a plain white page, but you can at least create link `back to your profile' or `Home'

lias’s picture

subscribing

netentropy’s picture

i thought the new buddy list required node profie....

timech187’s picture

I have been using a method to replace the current Profile module following the instructions located here: http://drupal.org/node/35728 as well as using the following link to add a file attachment to the profile: http://drupal.org/node/150318#comment-240662

Both ways work fine, but I want attributes from both. I would like the usernames to show up side by side, first name then last name, not in a list. Then I'd like other fields to show up like normal and THEN the file attachment.

All I want, is to be able to attach a document (.doc, .pdf, etc) to the Profile. I can add the field and they can even attach it, however, when I use the above link to create a custom look for my profile, I don't know how to get the attachment to show back up. It shows up before I start the customization process when I use the basic profile with those instructions.

Not only do I want it to show up, I want it to be under the rest of the profile information.

Thanks for any help!
Timech

lainel’s picture

Does anyone know how to embed the onlinestatus module into the user_profile file?

Muslim guy’s picture

<?php
print "<div class=\"fields\">";
print "Status ";
$time_period = variable_get('user_block_seconds_online', 2700);
$uid = arg(1); // get the current userid that is being viewed.
$users = db_query("SELECT uid, name, access FROM {users} WHERE access >= %d AND uid = $uid", time() - $time_period);
          $total_users = db_num_rows($users);

          if ($total_users == 1) {
            $output = t(' ::  Online');
          }
          else {
            $output = t(' ::  Offline');     
          }

              print $output;
                      print "</div>";
?>





I havent tried to display an icon/image, try adding something to $output = t(' :: Online');

lainel’s picture

Sorry for not explaining enough,
I mean the online status module for: aim,yahoo messanger,msn messanger,etc.
Any help would be greatly appreciated.

Muslim guy’s picture

<a href="http://messenger.yahoo.com/edit/send/?.target=yahooid">
<img border=0 src="http://opi.yahoo.com/online?u=yahooid&m=g&t=2&l=us"></a>

Replace yahooid with the username without @yahoo.com

So you need to ask user to fill in the username, in a textfield (one line), in profile_ym

To put this in user-profile.tpl.php:

<a href="http://messenger.yahoo.com/edit/send/?.target=<?php print $user->profile_ym ?>">
<img border=0 src="http://opi.yahoo.com/online?u=<?php print $user->profile_ym ?>&m=g&t=2&l=us"></a>
lainel’s picture

Thanks for that code,
Two more things if you don't mind.

1. Do you know how users can have their own url for their profile?(like myspace)

2. User designing there own profile layout(Like myspace too)

Any help would be greatly appreciated.

Muslim guy’s picture

Thats the point of calling for profile_css at the top of the user-profile.tpl.php

Its already presented above, find and study it closely :)

You can choose which default theme with the easiest to change

Garland for example, can enable a user to `hide' completely the left or right column

For most, Foliage is ok

lainel’s picture

One More Question,
Is there anyway I can have seperate themes?
Example: Lets say that I wan't my site theme garland, and when someone click a profile, it automatically switches to foliage.And when someone clicks any other page that's not a profile it goes back to garland.
Do you think this is possible?

Muslim guy’s picture

Interesting

I used a page-index.tpl.php and page.tpl.php with some small code in template.php

This will switch the page layout (front page is different from other pages and user profiles) but still the same theme.

You might want to visit Lullabot.com and pester them to write this code for us :) They are nice guys and a lot of free codes and improvements for Drupal in Lullabot

lainel’s picture

Do you have a code to allow user to rate other users?

mike.hobo’s picture

This can be done with fivestar and usernode.

mike.hobo’s picture

I know how the buddylist module can show your buddylist, but I am using buddylist as more of a bookmark, so your buddylist would be "My Favorite users" and then the "Buddy of" list will show "fans of janet" or something...

How can I do this? I know there is a buddyoflist function..

enky’s picture

interesting post, subscribing.

Phillip Mc’s picture

well worth bookmarking this handbook page:

Customising the User Profile layout.

lfhubcom’s picture

Are any revisions in the works for 6.2 users?
Thank you.

Pushkar Gaikwad’s picture

ditto :) Will surely implement some code in coming days ...

lainel’s picture

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 0, 5' at line 1 query: SELECT DISTINCT(node.nid), active, node.title AS node_title, node.changed AS node_changed, forward_statistics.clickthrough_count AS forward_statistics_clickthrough_count, forward_statistics.forward_count AS forward_statistics_forward_count FROM node node LEFT JOIN forward_statistics forward_statistics ON node.nid = forward_statistics.nid ORDER BY DESC LIMIT 0, 5 in /home/lainel/public_html/spikedout/includes/database.mysql.inc on line 172.

Can I get some help?

Liliplanet’s picture

Hi,

I'm trying to include the user gallery into my user's profile page please ...

Created a view call gallery-user, but all I get is a link on the page to the gallery.

<div id="user-gallery"><?php $view = views_get_view('gallery_user');
print views_build_view('embed', $view, array(strval($profileuser->uid)), false, false);   
?></div>

with this effort, it only shows 1 image ..

<?php

// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('gallery', $node->uid);

print l($nodeprofilenode->field_galleryimage[0]['value'],'user/' . $nodeprofilenode->uid)
?>

Any suggestions would be most appreciated.

Thank you.
Lilian

lainel’s picture

Try this one, It embeds the gallery on my user's profiles. If you want to change the amount of images to be shown, change the "$nlimit =type amount to be shown, here.

// 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 = 20;
$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;    replace with   $userid = arg(1);  
// If you want to put this in a block - create a custom block and set it to only show up on user/*

$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;

mirian’s picture

Hello!

I want to change the layout and design of the user profile EDIT page.
Any idea how to do it?

Miriam N.

mike.hobo’s picture

I think this involves changing the registration form theme.

mrgoltra’s picture

add

lainel’s picture

I've figured out the code to embed your user's aim, yahoo msng, msn msng, etc.
The module is called "online status".


$items = array();
foreach (onlinestatus_get_messengers(true) as $messenger => $title) 
{
if (empty ($user->$messenger)) 
{
continue;
}
$status = onlinestatus_messenger('status', $messenger, $user);
$image = theme('onlinestatus_indicator', $user, $messenger);
$url = onlinestatus_messenger('url', $messenger, $user);
$items[] = array('value' => sprintf('%s <a href="%s">%s (%s)</a>', $image, $url, $user->$messenger, $status),); 
}

foreach ($items as $term)
{
print($term['value']) . "<br>";
}
k4rine’s picture

hello,

excuse me for my english, ...

but Is it possible to have a module wich a counter to have the most visited for a profile's user?

because I will create a block on my home page to have a selection per profile most visited.

thanks,
karine

lainel’s picture

Is there any way I can convert the private message module to 6?

Muslim guy’s picture

One idea is to integrate Facebook account with your user's profile. Many people have FB accounts but they are hard to manage, and FB profiles suffer the same like MySpace - too much glitters, will crash your browsers, and most people avoid visiting FB profiles anyway (hate that forwarded junks on the FunWall)

1. Use iframe so the user's public profile can be viewed (and some friends)

You might want to set which part is loaded (view the main profile / view friends / Home / Notes )

2. The user can login straight (profile in profile)

3. Use `virtual pagination (AJAX)' so that in Drupal, a visitor to a profile can click a tab `Facebook profile' if he wishes to, otherwise the FB wont get displayed straightaway

4. Just use URL with target=_blank (open in new tab/window)

5. Use Drupal FB module

6. If the user wishes to instead display other people's profile, or Fan Profile, i think the URL is different so you need to have different link/iframe

lainel’s picture

Do you know anyway to allow user to renam thier pofile path? Like myspace.com/username
or how myspace allos user to name their url for their profile?

72dpi’s picture

download pathauto and give that a whirl.

Works like a charm, but go thru the settings (try on a testbed first)...

hope that helps

lainel’s picture

Thanks man, this really does work like a charm.

lutzl’s picture

i´m looking for a way to show the location of a user in his profile in a google map. any ideas?

Liliplanet’s picture

Hi,

Please how do I

1. add line breaks to a multi-line field. Currently the code is:

print $node->field_detailed_profile[0]['value']

but has no line breaks and just one continuous line.

2. have weblinks and email addresses appear automatically as in full or filtered html. Now it's just plain text.

Would most appreciate any suggestions.

Lilian

Liliplanet’s picture

Hi,

Been checking every day just in case someone has an answer for me please truly cannot find the solution on the forums.

I would like to include a field on my node-proflle.tpl.php, but it is a textarea for the user. When I include:

<div><?php print $node->field_introduction[0]['value'] ?></div>
<div><?php print $node->field_detailed_profile[0]['value'] ?></div>

it just prints out as straight text without line breaks or any formatting for weblinks, email addresses, etc.

Please how do I format the above so that it prints in the node-profile template as it was created by the user?

Would most appreciate any reply.

Lilian

Michelle’s picture

Try changing 'value' to 'view'.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Liliplanet’s picture

I tried that and still no joy ..

see: http://www.ufilm.tv/member/redoneafrica

<center><div class="field field-type-text field-field-introduction">
 <div class="field-items">
      <div class="field-item"><b><h2><?php print $node->field_introduction[0]['view'] ?></b></h2></div>
  </div>
</div></center>

<div class="field field-type-text field-field-detailed-profile">
 <div class="field-items">
      <div class="field-item"><?php print $node->field_detailed_profile[0]['view'] ?></div>
  </div>
</div>

the introduction and description just has no format. Michelle, is there perhaps another way to do this, or is this the way to go?

Look so so forward to your reply and thank you again.
Lilian

Michelle’s picture

That should run it through the filters. Double check your fields to be sure you didn't set them to plain text.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Liliplanet’s picture

I tried that and still no joy ..

see: http://www.ufilm.tv/member/redoneafrica

<center><div class="field field-type-text field-field-introduction">
 <div class="field-items">
      <div class="field-item"><b><h2><?php print $node->field_introduction[0]['view'] ?></b></h2></div>
  </div>
</div></center>

<div class="field field-type-text field-field-detailed-profile">
 <div class="field-items">
      <div class="field-item"><?php print $node->field_detailed_profile[0]['view'] ?></div>
  </div>
</div>

the introduction and description just has no format. Michelle, is there perhaps another way to do this, or is this the way to go?

Look so so forward to your reply and thank you again.
Lilian

Liliplanet’s picture

My goodness Michelle, it was that easy!? Yip, all to done was select filtered text.

I've been struggling for days inserting custom view etc etc. You are a super-star! Thank you so much!

Lilian

Michelle’s picture

Glad you got it working. :)

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Muslim guy’s picture

Michelle, thanks for the tutorials :)

Is there any way to make the page count (statistics) to also read a user's profile? Or should we use a script whether internal or external to count?

Michelle’s picture

I don't know if statistics can be made to do it but there is this module: http://drupal.org/project/user_visits

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

lainel’s picture

Does anyone know how to have certain profile information different from another role?
Like:

(Role 1 Profile)
Name: blah
weight: 100

(Role 2 Profile)
Name: Blah
Age: Blah

(Role 3 Profile)
Name: Blah
Ethnic: Blah

If you know how this works can you share that information with me?

Thanks

mike.hobo’s picture

As of now, I have yet to find anything that can change the profile edit form accordingly, but on the profile you can. You can use this code:

Name: <? print $user->name ?>
<?php if ($role == 1): ?>
Weight: <? print $user->weight ?>
<?php endif;?>

<?php if ($role == 2): ?>
Age: <? print $user->age ?>
<?php endif;?>

<?php if ($role == 3): ?>
Ethnic: <? print $user->blah ?>
<?php endif;?>

Just change it to the correct role id's and change whatever else you need. I think my coding sucks, I think you probably could use "elseif" statements instead of ending all the ifs.

mike.hobo’s picture

Displays the number of plays for all of a users audio.

<?php
$uid = $user->uid;
$plays = db_fetch_object(db_query("SELECT SUM(play_count) AS count FROM {audio} JOIN {node} WHERE audio.nid = node.nid AND node.uid = %d", $uid));
echo "This member's audio files have been played $plays->count times";
?>
lainel’s picture

This is just awesome Man, thanks.
You wouldn't happen to have a code where users can get an embed code from an audio node would you?

minesota’s picture

subscribed

mike.hobo’s picture

@lainel

This is unrelated to the user profile, but if you mean like youtube's embed, go here http://drupal.org/node/270611#comment-883257

lainel’s picture

Hi, does anyone know how to change the theme on profile pages?

Can some share the code to insert inside of the style.css page, will you please share that?

Muslim guy’s picture

It depends on what theme you use

Foliage is the easiest

You can instruct the users to change what code for colors, fonts, even hide left/right sidebars, and also user's own banner in the header

Muslim guy’s picture

It depends on what theme you use

Foliage is the easiest

You can instruct the users to change what code for colors, fonts, even hide left/right sidebars, and also user's own banner in the header

minesota’s picture

Hello, have you any clue or solution to this issue ?
http://drupal.org/node/274543

lainel’s picture

Hey, on my profile I am trying to get tables aligned right next to each other, like myspace, youtube, etc.

If anyone has an example, or code. Can you share that please?

My html table codes suck right now.

pribeh’s picture

gowthami_p’s picture

custom user_profile.tpl.php - Link to a second page displaying user info from certain profile category

I have profile category with serveral profile_fields to be filled in by the user.

I don't want to display all these fields on my default (or first) user_profile.tpl.php page.

I want to display a link on this user profile page which would take you off to another page displaying the results from the new profile category and fields.

So essentially I want to split a users profile over two pages somehow.

Any ideas how I can do this?

Thanks, gowthami.

gowthami_p’s picture

custom user_profile.tpl.php - Link to a second page displaying user info from certain profile category

I have profile categories with serveral profile_fields to be filled in by the user.

I don't want to display all these fields on my default (or first) user_profile.tpl.php page.

I want to display a link on this user profile page which would take you off to another page displaying the results from the new profile category and fields. (Like View Full profile)

So essentially I want to split a users profile over two pages somehow. Any ideas how I can do this?

Thanks,
gowthami.