About the author

Photo of sanduhrs
sanduhrs

Drupal User Interests Module

The User Interests Module [1] is a module for the fabulous Drupal Web Content Management System [2]. It is a small and simple Module, which shows a user's most used taxonomy terms on the profile page.

Drupal user profile page with interests list

Many people customize the user profile layout [3] with a technique described on drupal.org.
In this case too, you may display the user's interests with a simple function call wherever you want, just do

<?php
 
print theme('user_interests', $user->user_interests);
?>

And you also may override the themeable function, by placing it in your template.php. You may modify it as you like.

<?php
function phptemplate_user_interests($items = array(), $title = NULL, $type = 'ul', $attributes = NULL, $limit = 10) {
 
$i = 0;
 
$output = '<div class="user-interests">';
  if (isset(
$title)) {
   
$output .= '<h3>'. $title .'</h3>';
  }

  if (!empty(
$items)) {
   
$output .= "<$type" . drupal_attributes($attributes) . '>';
    foreach (
$items as $item) {
     
$i++;
     
$attributes = array();
     
$children = array();
      if (
is_array($item)) {
        foreach (
$item as $key => $value) {
          if (
$key == 'data') {
           
$data = $value;
          }
          elseif (
$key == 'children') {
           
$children = $value;
          }
          else {
           
$attributes[$key] = $value;
          }
        }
      }
      else {
       
$data = $item;
      }
      if (
count($children) > 0) {
       
$data .= theme_item_list($children, NULL, $type, $attributes); // Render nested list
     
}
     
$output .= '<li' . drupal_attributes($attributes) . '>'. $data .'</li>';
      if (
$i >= $limit) break;
    }
   
$output .= "</$type>";
  }
 
$output .= '</div>';
  return
$output;
}
?>

Weblinks
[1] http://drupal.org/project/user_interests
[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.