Add URL field from Userlinks Module to Views

Last modified: March 28, 2007 - 05:28

This include file for the modules Views (/modules/views/modules/views_userlink.inc) implements views functionality for userlink.module.

<?php
/**
* $Id: views_userlink.inc,v 1.10 2006/06/21 12:01:19 chris_five Exp $
*/
function userlink_views_tables() {
  if (
module_exist('userlink')) {

   
$tables['userlink'] = array(
       
'name' => 'userlink',
       
'provider' => 'internal',
   
'join' => array(
     
'left' => array(
       
'table' => 'node',
       
'field' => 'nid'
     
),
     
'right' => array(
       
'field' => 'nid'
     
),
    ),
       
'fields' => array(
           
'url' => array(
               
'name' => t('Userlink: URL'),
               
'handler' => 'views_handler_userlink_url',
               
'sortable' => false,
               
'help' => t("The URL field will display the URL of a userlink node (for example, 'http://www.drupal.org')")
                ),
        )
    );
    return
$tables;
    }
}

function
views_handler_userlink_url($fieldinfo, $fielddata, $value, $data) {
    return
l($value, $value);
}
?>

Based on work by vadbars (http://drupal.org/node/68931)

Change of function name in Drupal 5

diego_miola - March 12, 2007 - 15:32

You must replace "module_exist" function to "module_exists" in order to make this snippet work on Drupal 5.

http://drupal.org/node/64279#module-exists

Diego.

No Longer necessary

roychri - June 25, 2009 - 14:11

The latest version of userlink module (5.x-1.2) already support integration with views.
Using the code in this page will result in Fatal error: Cannot redeclare userlink_views_tables()

--
PHP5 Zend Certified Engineer
Christian Roy

 
 

Drupal is a registered trademark of Dries Buytaert.