api-8.x-1.x-dev/src/Plugin/views/style/HtmlDlList.php
src/Plugin/views/style/HtmlDlList.php
<?php
namespace Drupal\api\Plugin\views\style;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\style\StylePluginBase;
/**
* Style plugin to render each item in an dl/dd list.
*
* @ViewsStyle(
* id = "html_dl_list",
* title = @Translation("HTML DL List"),
* help = @Translation("Displays rows as HTML DL list."),
* theme = "views_view_dl_list",
* display_types = {"normal"}
* )
*/
class HtmlDlList extends StylePluginBase {
/**
* {@inheritdoc}
*/
protected $usesRowPlugin = TRUE;
/**
* Does the style plugin support custom css class for the rows.
*
* @var bool
*/
protected $usesRowClass = FALSE;
/**
* Set default options.
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['type'] = ['default' => 'dl'];
$options['class'] = ['default' => ''];
$options['wrapper_class'] = ['default' => 'item-list'];
return $options;
}
/**
* Render the given style.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['type'] = [
'#type' => 'radios',
'#title' => $this->t('List type'),
'#options' => [
'dl' => $this->t('DL list'),
],
'#default_value' => $this->options['type'],
];
$form['wrapper_class'] = [
'#title' => $this->t('Wrapper class'),
'#description' => $this->t('The class to provide on the wrapper, outside the list.'),
'#type' => 'textfield',
'#size' => '30',
'#default_value' => $this->options['wrapper_class'],
];
$form['class'] = [
'#title' => $this->t('List class'),
'#description' => $this->t('The class to provide on the list element itself.'),
'#type' => 'textfield',
'#size' => '30',
'#default_value' => $this->options['class'],
];
}
}
