Community Documentation

New Field Type "Upload: File Name" in module Views

Last updated June 14, 2006. Created by vadbars on June 14, 2006.
Log in to edit this page.

This include file for module Views (/modules/views/modules/views_upload.inc) implements views functionality on behalf of upload.module.

<?php
// $Id: views_upload.inc,v 1.1 2006/06/12 21:44:53 vadbars Exp $
function upload_views_tables() {
 
$tables['files'] = array(
   
'name' => 'files',
   
'provider' => 'internal',
   
'join' => array(
     
'left' => array(
       
'table' => 'node',
       
'field' => 'nid'
     
),
     
'right' => array(
       
'field' => 'nid'
     
),
    ),
   
'fields' => array(
     
'filename' => array(
       
'name' => t('Upload: File Name'),
       
'sortable' => true,
       
'handler' => 'views_handler_field_filename',
       
'option' => string,
       
'help' => t('This will display the file name.'),
      ),
    ),
  );
  return
$tables;
}

function
views_handler_field_filename($fieldinfo, $fielddata, $value, $data) {
return
l($value, 'files/'.$value);
}
?>

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.