3 namespace Drupal\views\Plugin\views\style;
5 use Drupal\Core\Form\FormStateInterface;
8 * The default style plugin for summaries.
10 * @ingroup views_style_plugins
13 * id = "default_summary",
14 * title = @Translation("List"),
15 * help = @Translation("Displays the default summary as a list."),
16 * theme = "views_view_summary",
17 * display_types = {"summary"}
20 class DefaultSummary extends StylePluginBase {
22 protected function defineOptions() {
23 $options = parent::defineOptions();
25 $options['base_path'] = ['default' => ''];
26 $options['count'] = ['default' => TRUE];
27 $options['override'] = ['default' => FALSE];
28 $options['items_per_page'] = ['default' => 25];
33 public function query() {
34 if (!empty($this->options['override'])) {
35 $this->view->setItemsPerPage(intval($this->options['items_per_page']));
39 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
40 $form['base_path'] = [
41 '#type' => 'textfield',
42 '#title' => $this->t('Base path'),
43 '#default_value' => $this->options['base_path'],
44 '#description' => $this->t('Define the base path for links in this summary
45 view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
46 Do not include beginning and ending forward slash. If this value
47 is empty, views will use the first path found as the base path,
48 in page displays, or / if no path could be found.'),
51 '#type' => 'checkbox',
52 '#default_value' => !empty($this->options['count']),
53 '#title' => $this->t('Display record count with link'),
56 '#type' => 'checkbox',
57 '#default_value' => !empty($this->options['override']),
58 '#title' => $this->t('Override number of items to display'),
61 $form['items_per_page'] = [
62 '#type' => 'textfield',
63 '#title' => $this->t('Items to display'),
64 '#default_value' => $this->options['items_per_page'],
67 ':input[name="options[summary][options][' . $this->definition['id'] . '][override]"]' => ['checked' => TRUE],
73 public function render() {
75 foreach ($this->view->result as $row) {
76 // @todo: Include separator as an option.
81 '#theme' => $this->themeFunctions(),
82 '#view' => $this->view,
83 '#options' => $this->options,