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, 'bool' => TRUE);
  20. $options['summary'] = array('default' => '');
  21. $options['caption'] = array('default' => '');
  22. return $options;
  23. }
  24. /**
  25. * Render the given style.
  26. */
  27. function options_form(&$form, &$form_state) {
  28. parent::options_form($form, $form_state);
  29. $form['columns'] = array(
  30. '#type' => 'textfield',
  31. '#title' => t('Number of columns'),
  32. '#default_value' => $this->options['columns'],
  33. '#required' => TRUE,
  34. '#element_validate' => array('views_element_validate_integer'),
  35. );
  36. $form['alignment'] = array(
  37. '#type' => 'radios',
  38. '#title' => t('Alignment'),
  39. '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')),
  40. '#default_value' => $this->options['alignment'],
  41. '#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.'),
  42. );
  43. $form['fill_single_line'] = array(
  44. '#type' => 'checkbox',
  45. '#title' => t('Fill up single line'),
  46. '#description' => t('If you disable this option, a grid with only one row will have the same number of table cells (<TD>) as items. Disabling it can cause problems with your CSS.'),
  47. '#default_value' => !empty($this->options['fill_single_line']),
  48. );
  49. $form['caption'] = array(
  50. '#type' => 'textfield',
  51. '#title' => t('Short description of table'),
  52. '#description' => t('Include a caption for better accessibility of your table.'),
  53. '#default_value' => $this->options['caption'],
  54. );
  55. $form['summary'] = array(
  56. '#type' => 'textfield',
  57. '#title' => t('Table summary'),
  58. '#description' => t('This value will be displayed as table-summary attribute in the html. Use this to give a summary of complex tables.'),
  59. '#default_value' => $this->options['summary'],
  60. );
  61. }
  62. }