class DefaultSummary
Same name and namespace in other branches
- 11.x core/modules/views/src/Plugin/views/style/DefaultSummary.php \Drupal\views\Plugin\views\style\DefaultSummary
- 10 core/modules/views/src/Plugin/views/style/DefaultSummary.php \Drupal\views\Plugin\views\style\DefaultSummary
- 8.9.x core/modules/views/src/Plugin/views/style/DefaultSummary.php \Drupal\views\Plugin\views\style\DefaultSummary
The default style plugin for summaries.
Plugin annotation
@ViewsStyle(
id = "default_summary",
title = @Translation("List"),
help = @Translation("Displays the default summary as a list."),
theme = "views_view_summary",
display_types = {"summary"}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\style\StylePluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\style\DefaultSummary extends \Drupal\views\Plugin\views\style\StylePluginBase
- class \Drupal\views\Plugin\views\style\StylePluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of DefaultSummary
Related topics
1 file declares its use of DefaultSummary
- Result.php in core/
modules/ views/ src/ Plugin/ views/ area/ Result.php
1 string reference to 'DefaultSummary'
- ArgumentPluginBase::defaultActions in core/
modules/ views/ src/ Plugin/ views/ argument/ ArgumentPluginBase.php - Default actions.
File
-
core/
modules/ views/ src/ Plugin/ views/ style/ DefaultSummary.php, line 20
Namespace
Drupal\views\Plugin\views\styleView source
class DefaultSummary extends StylePluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
$options['base_path'] = [
'default' => '',
];
$options['count'] = [
'default' => TRUE,
];
$options['override'] = [
'default' => FALSE,
];
$options['items_per_page'] = [
'default' => 25,
];
return $options;
}
public function query() {
if (!empty($this->options['override'])) {
$this->view
->setItemsPerPage(intval($this->options['items_per_page']));
}
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['base_path'] = [
'#type' => 'textfield',
'#title' => $this->t('Base path'),
'#default_value' => $this->options['base_path'],
'#description' => $this->t('Define the base path for links in this summary
view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
Do not include beginning and ending forward slash. If this value
is empty, views will use the first path found as the base path,
in page displays, or / if no path could be found.'),
];
$form['count'] = [
'#type' => 'checkbox',
'#default_value' => !empty($this->options['count']),
'#title' => $this->t('Display record count with link'),
];
$form['override'] = [
'#type' => 'checkbox',
'#default_value' => !empty($this->options['override']),
'#title' => $this->t('Override number of items to display'),
];
$form['items_per_page'] = [
'#type' => 'textfield',
'#title' => $this->t('Items to display'),
'#default_value' => $this->options['items_per_page'],
'#states' => [
'visible' => [
':input[name="options[summary][options][' . $this->definition['id'] . '][override]"]' => [
'checked' => TRUE,
],
],
],
];
}
public function render() {
$rows = [];
foreach ($this->view->result as $row) {
// @todo: Include separator as an option.
$rows[] = $row;
}
return [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $rows,
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.