You are here

class views_handler_field_quotes in Quotes 6

Same name and namespace in other branches
  1. 7 views_handler_field_quotes.inc \views_handler_field_quotes

Field handler to provide an embedded image.

Hierarchy

Expanded class hierarchy of views_handler_field_quotes

1 string reference to 'views_handler_field_quotes'
quotes_views_data in ./quotes.views.inc
Implementation of hook_views_data().

File

./views_handler_field_quotes.inc, line 12
Provide views data and handlers for quotes.module

View source
class views_handler_field_quotes extends views_handler_field {

  /**
   * Define options available for this field.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['author_link'] = array(
      'default' => 'text',
    );
    return $options;
  }

  /* */

  /**
   * Build option configuration form.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['author_link'] = array(
      '#title' => t('Show author as'),
      '#type' => 'radios',
      '#options' => array(
        'text' => 'Text',
        'author' => 'Link to quotes',
      ),
      '#default_value' => $this->options['author_link'],
    );
  }

  /* */

  /**
   * Render field output to the browser.
   */
  function render($values) {

    //   drupal_set_message(print_r($values, true));
    $author = $values->{$this->field_alias};
    $type = $this->options['author_link'];

    //   drupal_set_message("\$this->field_alias='$this->field_alias', author='$author', type='$type'.");
    switch ($type) {
      case 'author':
        return l($author, 'quotes/author/' . check_plain($author), array(
          'attributes' => array(
            'rel' => 'tag',
          ),
        ));
      default:

        // Also 'text'
        return check_plain($author);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_handler_field_quotes::options_form function Build option configuration form.
views_handler_field_quotes::option_definition function Define options available for this field.
views_handler_field_quotes::render function Render field output to the browser.