Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. class Slider extends StylePluginBase {
  2.  
  3.  
  4.  
  5. /**
  6. * {@inheritdoc}
  7. */
  8. protected function defineOptions() {
  9. $options = parent::defineOptions();
  10. $options['path'] = array('default' => 'slider');
  11. return $options;
  12. }
  13.  
  14. /**
  15.  
  16.  
  17.  
  18. * Does the style plugin for itself support to add fields to its output.
  19. *
  20. * @var bool
  21. */
  22. protected $usesFields = TRUE;
  23.  
  24.  
  25.  
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  30. parent::buildOptionsForm($form, $form_state);
  31.  
  32. // Path prefix for SLIDER links.
  33.  
  34. $form['chooseImage'] = [
  35. '#title' => $this->t('Choose Image'),
  36. '#type' => 'select',
  37. '#description' => t('Choose where to position the title and text in the slider'),
  38. '#options' => ['cc' => $this->t('Center'), 'tl' => $this->t('Top Left')],
  39. ];
  40.  
  41. }
  42.  
  43. function slider_theme($existing, $type, $theme, $path) {
  44. return array(
  45. 'slider' => array(
  46. 'file' => 'extended_display_styles.theme.inc',
  47.  
  48. ),
  49. );
  50. }
  51.  
  52. function template_preprocess_views_view_slider(&$variables) {
  53. // View options set by user.
  54.  
  55.  
  56. $options = $variables['view']->style_plugin->options;
  57.  
  58. // Build a two-dimension array with years and months.
  59. $time_pool = array();
  60. $frameArrayManual = array('a','b','c');
  61. //$options['manual'] = $variables['view']->style_plugin->manual;
  62.  
  63. foreach ($variables['view']->result as $id => $result) {
  64. $created = $result->node_field_data_created;
  65. $created_year = date('Y', $created);
  66. // Month date format.
  67. $month_date_format = (isset($options['month_date_format'])) ? $options['month_date_format'] : 'm';
  68. $created_month_digits = date('m', $created);
  69. $created_month = date($month_date_format, $created);
  70. $time_pool[$created_year][$created_month_digits] = "$created_month";
  71. }
  72.  
  73. $options['time_pool'] = $time_pool;
  74. $options['frameArrayManual'] = array('a','b','c');
  75.  
  76. // Update options for twig.
  77. $variables['options'] = $options;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement