Community Documentation

Add URL field from Userlinks Module to Views

Last updated March 28, 2007. Created by chris_five on June 22, 2006.
Log in to edit this page.

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)

Comments

Change of function name in Drupal 5

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.

----
Diego Miola
http://www.devjaus.com/

No Longer necessary

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()

--
Drupal Freelancer (Module Developer)
Christian Roy

Thanks

Oh, I remember facing this problem when building file upload web service.
Thank you for this post.

About this page

Drupal version
Drupal 4.7.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here