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

Drupal example source code file (views_handler_field_node_type.inc)

This example Drupal source code file (views_handler_field_node_type.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, check_plain, data, extends, form, form_state, function, machine, name, options, php, return, type, values

The views_handler_field_node_type.inc Drupal example source code

// $Id: views_handler_field_node_type.inc,v 2010/04/29 18:33:29 merlinofchaos Exp $

 * Field handler to translate a node type into its readable form.
class views_handler_field_node_type extends views_handler_field_node {
  function option_definition() {
    $options = parent::option_definition();
    $options['machine_name'] = array('default' => FALSE);

    return $options;

   * Provide machine_name option for to node type display.
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['machine_name'] = array(
      '#title' => t('Output machine name'),
      '#description' => t('Display field as the node type machine name.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['machine_name']),

    * Render node type as human readable name, unless using machine_name option.
  function render_name($data, $values) {
    if ($this->options['machine_name'] != 1 && $data !== NULL && $data !== '') {
      return t(check_plain(node_type_get_name($data)));
    return check_plain($data);

  function render($values) {
    return $this->render_link($this->render_name($values->{$this->field_alias}, $values), $values);

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_field_node_type.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.