Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Slider extends StylePluginBase {
- /**
- * {@inheritdoc}
- */
- protected function defineOptions() {
- $options = parent::defineOptions();
- $options['path'] = array('default' => 'slider');
- return $options;
- }
- /**
- * Does the style plugin for itself support to add fields to its output.
- *
- * @var bool
- */
- protected $usesFields = TRUE;
- /**
- * {@inheritdoc}
- */
- public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- parent::buildOptionsForm($form, $form_state);
- // Path prefix for SLIDER links.
- $form['chooseImage'] = [
- '#title' => $this->t('Choose Image'),
- '#type' => 'select',
- '#description' => t('Choose where to position the title and text in the slider'),
- '#options' => ['cc' => $this->t('Center'), 'tl' => $this->t('Top Left')],
- ];
- }
- function slider_theme($existing, $type, $theme, $path) {
- return array(
- 'slider' => array(
- 'file' => 'extended_display_styles.theme.inc',
- ),
- );
- }
- function template_preprocess_views_view_slider(&$variables) {
- // View options set by user.
- $options = $variables['view']->style_plugin->options;
- // Build a two-dimension array with years and months.
- $time_pool = array();
- $frameArrayManual = array('a','b','c');
- //$options['manual'] = $variables['view']->style_plugin->manual;
- foreach ($variables['view']->result as $id => $result) {
- $created = $result->node_field_data_created;
- $created_year = date('Y', $created);
- // Month date format.
- $month_date_format = (isset($options['month_date_format'])) ? $options['month_date_format'] : 'm';
- $created_month_digits = date('m', $created);
- $created_month = date($month_date_format, $created);
- $time_pool[$created_year][$created_month_digits] = "$created_month";
- }
- $options['time_pool'] = $time_pool;
- $options['frameArrayManual'] = array('a','b','c');
- // Update options for twig.
- $variables['options'] = $options;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement