brrocks28
6/4/2015 - 1:09 PM

add new custom field in view view handler create a folder view and add two inc files refer: https://kalamuna.atlassian.net/wiki/display/KAL

add new custom field in view view handler create a folder view and add two inc files

refer: https://kalamuna.atlassian.net/wiki/display/KALA/Custom+Views+Field+Handler


// THIS IS FOR Handler
//THIS FILE SHOULD BE IN VIEWS FOLDER WITH FILE NAME userregistration_handler_handlername.inc

<?php
class userregistration_handler_handlername extends views_handler_field {
  function option_definition() {
    $options = parent::option_definition();
    return $options;
  }
  
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
  }
  
  function query() {
    // do nothing -- to override the parent query.
  }
  
  function render($data) {
    // If the devel module is enabled, you may view all of the
    // data provided by fields previously added in your view.
    // dpm($data);
    // Insert PHP code here, or display greeting.
    $output = t("Hello World!");
    return $output; 
  }
}


<?php

// THIS IS FOR DATA
//THIS FILE SHOULD BE IN VIEWS FOLDER WITH FILE NAME hook.views.inc

function userregistration_views_data() {
  $data = array();
  $data['node']['handlername'] = array(
    'title' => t('Bhavesh'),
    'help' => t('Description of my handler (bha).'),
    'field' => array(
      'handler' => 'userregistration_handler_handlername',
    ),
  );
  return $data;
}

//write this in .module file

include "views/hook_handler_handlername.inc";
function hook_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'userregistration') . '/views',
  );
}