You are here

views_plugin_style_sgrid.inc in Sortable Grid Views Plugin 7

Same filename and directory in other branches
  1. 6 views_plugin_style_sgrid.inc

Views style plugin for Sortable grid module

File

views_plugin_style_sgrid.inc
View source
<?php

/**
 * @file
 * Views style plugin for Sortable grid module
 */
class views_plugin_style_sgrid extends views_plugin_style_list {

  /**
   * Set default options
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['type'] = array(
      'default' => 'ul',
    );
    $options['class'] = array(
      'default' => '',
    );
    $options['wrapper_class'] = array(
      'default' => 'item-list',
    );
    $options['row_length'] = array(
      'default' => '4',
    );
    return $options;
  }

  /**
   * Render the given style.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['type'] = array(
      '#type' => 'radios',
      '#title' => t('List type'),
      '#options' => array(
        'ul' => t('Unordered list'),
        'ol' => t('Ordered list'),
      ),
      '#default_value' => $this->options['type'],
    );
    $form['wrapper_class'] = array(
      '#title' => t('Wrapper class'),
      '#description' => t('The class to provide on the wrapper, outside the list.'),
      '#type' => 'textfield',
      '#size' => '30',
      '#default_value' => $this->options['wrapper_class'],
    );
    $form['class'] = array(
      '#title' => t('List class'),
      '#description' => t('The class to provide on the list element itself.'),
      '#type' => 'textfield',
      '#size' => '30',
      '#default_value' => $this->options['class'],
    );
    $form['row_length'] = array(
      '#title' => t('Row length'),
      '#description' => t('How many items should be displayed before a line break ?'),
      '#type' => 'textfield',
      '#size' => '2',
      '#default_value' => $this->options['row_length'],
    );
  }

  /**
   * Render the display in this style.
   */
  function render() {
    if ($this
      ->uses_row_plugin() && empty($this->row_plugin)) {
      debug('views_plugin_style_default: Missing row plugin');
      return;
    }

    // Group the rows according to the grouping field, if specified.
    $sets = $this
      ->render_grouping($this->view->result, $this->options['grouping']);

    // Render each group separately and concatenate.  Plugins may override this
    // method if they wish some other way of handling grouping.
    $output = '';
    foreach ($sets as $title => $records) {
      if ($this
        ->uses_row_plugin()) {
        $rows = array();
        foreach ($records as $row_index => $row) {
          $this->view->row_index = $row_index;
          $rows[$row_index] = $this->row_plugin
            ->render($row);
        }
      }
      else {
        $rows = $records;
      }
      $output .= theme($this
        ->theme_functions(), array(
        'view' => $this->view,
        'options' => $this->options,
        'rows' => $rows,
        'title' => $title,
      ));
    }
    unset($this->view->row_index);
    return $output;
  }

}

Classes

Namesort descending Description
views_plugin_style_sgrid @file Views style plugin for Sortable grid module