About the author

Photo of sanduhrs
sanduhrs

Drupal User Visits Module

The User Visits Module [1] is a module for the exciting Drupal Web Content Management System [2]. Very lighweight and simple, it just remembers the users who visited another user's profile page.

Drupal user profile page with visitors list

If you want to customize the user profile layout [3] with the technique described on drupal.org, you may display the user's visitors with the following code

<?php
  $visitors
= user_visits_latest($user->uid);
  if (
is_array($visitors)) {
    foreach (
$visitors as $visitor) {
     
$user = user_load(array('uid' => $visitor->vuid));
     
$output = theme('user_visit', $user, $visitor->visit);
    }
  }
?>

And you also may override the themeable function, by placing it in your template.php. Modify it to your liking.

<?php
function phptemplate_user_visit($user, $timestamp = NULL) {
 
$output  = "<div class=\"profile\">\n";
 
$output .= theme('user_picture', $user);
 
$output .= ' <div class="name">'. theme('username', $user) ."</div>\n";
  if (
$timestamp) {
   
$output .= " <div class=\"visit\">". t('!time ago', array('!time' => format_interval(time() - $timestamp))) ."</div>\n";
  }
 
$output .= "</div>\n";

  return
$output;
}
?>

Weblinks
[1] http://drupal.org/project/user_visits
[2] http://drupal.org
[3] http://drupal.org/node/35728

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Website powered by lovely Drupal · Microformats · XML Feed · Valid XHTML, CSS · No www.