home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (views_handler_field_file_uri.inc)

This example Drupal source code file (views_handler_field_file_uri.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, data, download, empty, file, form, form_state, function, options, php, return, the, url, values

The views_handler_field_file_uri.inc Drupal example source code

// $Id: views_handler_field_file_uri.inc,v 2010/10/06 17:47:37 dereine Exp $

 * Field handler to add rendering file paths as file URLs instead of as internal file URIs.
class views_handler_field_file_uri extends views_handler_field_file {
  function option_definition() {
    $options = parent::option_definition();
    $options['file_download_path'] = array('default' => FALSE);
    return $options;

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['file_download_path'] = array(
      '#title' => t('Display download path instead of file storage URI'),
      '#description' => t('This will provide the full download URL rather than the internal filestream address.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['file_download_path']),

  function render($values) {
    $data = $values->{$this->field_alias};
    if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
      $data = file_create_url($data);
    return $this->render_link($data, $values);

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_field_file_uri.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.