Skip to main content
4 of 5
added 672 characters in body
niksmac
  • 7.7k
  • 3
  • 31
  • 69

How do I alter the output of an existing views handler?

How do I alter the output of an existing views handler?

I want to alter views_handler_field_user_picture() to get the link to the user profile, not the themed picture.

See alter existing handlers (handler overrides). I expect a link like this http://cdn.sstatic.net/drupal/img/logo.png.

function mymodule_views_data_alter(&$data) {
  $data['users']['field']['handler'] = 'my_custom_handler';
}

module .info

files[] = user_picture_formatter.inc

and user_picture_formatter.inc is like this

<?php
class my_custom_handler extends views_handler_field_user_picture {
  function render($values) {
    if ($picture_fid = $this->get_value($values)) {
      $picture = file_load($picture_fid);
      $picture_filepath = $picture->uri;
    }
    else {
      $picture_filepath = variable_get('user_picture_default', '');
    }
    return $picture_filepath;
  }
}
?>
niksmac
  • 7.7k
  • 3
  • 31
  • 69