class HtmlList

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/style/HtmlList.php \Drupal\views\Plugin\views\style\HtmlList

Style plugin to render each item in an ordered or unordered list.

Plugin annotation


@ViewsStyle(
  id = "html_list",
  title = @Translation("HTML List"),
  help = @Translation("Displays rows as HTML list."),
  theme = "views_view_list",
  display_types = {"normal"}
)

Hierarchy

Expanded class hierarchy of HtmlList

Related topics

File

core/modules/views/src/Plugin/views/style/HtmlList.php, line 20

Namespace

Drupal\views\Plugin\views\style
View source
class HtmlList extends StylePluginBase {
  
  /**
   * {@inheritdoc}
   */
  protected $usesRowPlugin = TRUE;
  
  /**
   * Does the style plugin support custom css class for the rows.
   *
   * @var bool
   */
  protected $usesRowClass = TRUE;
  
  /**
   * Set default options.
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['type'] = [
      'default' => 'ul',
    ];
    $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' => [
        'ul' => $this->t('Unordered list'),
        'ol' => $this->t('Ordered 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'],
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.