views_plugin_style_grid.inc

  1. 3.x plugins/views_plugin_style_grid.inc
  2. 2.x plugins/views_plugin_style_grid.inc

Contains the grid style plugin.

File

plugins/views_plugin_style_grid.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the grid style plugin.
  5. */
  6. /**
  7. * Style plugin to render each item in a grid cell.
  8. *
  9. * @ingroup views_style_plugins
  10. */
  11. class views_plugin_style_grid extends views_plugin_style {
  12. /**
  13. * Set default options
  14. */
  15. function option_definition() {
  16. $options = parent::option_definition();
  17. $options['columns'] = array('default' => '4');
  18. $options['alignment'] = array('default' => 'horizontal');
  19. $options['fill_single_line'] = array('default' => TRUE);
  20. $options['summary'] = array('default' => '');
  21. return $options;
  22. }
  23. /**
  24. * Render the given style.
  25. */
  26. function options_form(&$form, &$form_state) {
  27. parent::options_form($form, $form_state);
  28. $form['columns'] = array(
  29. '#type' => 'textfield',
  30. '#title' => t('Number of columns'),
  31. '#default_value' => $this->options['columns'],
  32. );
  33. $form['alignment'] = array(
  34. '#type' => 'radios',
  35. '#title' => t('Alignment'),
  36. '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')),
  37. '#default_value' => $this->options['alignment'],
  38. '#description' => t('Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.'),
  39. );
  40. $form['fill_single_line'] = array(
  41. '#type' => 'checkbox',
  42. '#title' => t('Fill up single line'),
  43. '#description' => t('If you disable this option a grid with only one row will have the amount of items as tds. If you disable it this can cause problems with your css.'),
  44. '#default_value' => !empty($this->options['fill_single_line']),
  45. );
  46. $form['summary'] = array(
  47. '#type' => 'textfield',
  48. '#title' => t('Table summary'),
  49. '#description' => t('This value will be displayed as table-summary attribute in the html. Set this for better accessiblity of your site.'),
  50. '#default_value' => $this->options['summary'],
  51. );
  52. }
  53. }