function StatisticsPopularBlock::build
Same name in other branches
- 8.9.x core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::build()
- 10 core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::build()
- 11.x core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::build()
Overrides BlockPluginInterface::build
File
-
core/
modules/ statistics/ src/ Plugin/ Block/ StatisticsPopularBlock.php, line 154
Class
- StatisticsPopularBlock
- Provides a 'Popular content' block.
Namespace
Drupal\statistics\Plugin\BlockCode
public function build() {
$content = [];
if ($this->configuration['top_day_num'] > 0) {
$nids = $this->statisticsStorage
->fetchAll('daycount', $this->configuration['top_day_num']);
if ($nids) {
$content['top_day'] = $this->nodeTitleList($nids, $this->t("Today's:"));
$content['top_day']['#suffix'] = '<br />';
}
}
if ($this->configuration['top_all_num'] > 0) {
$nids = $this->statisticsStorage
->fetchAll('totalcount', $this->configuration['top_all_num']);
if ($nids) {
$content['top_all'] = $this->nodeTitleList($nids, $this->t('All time:'));
$content['top_all']['#suffix'] = '<br />';
}
}
if ($this->configuration['top_last_num'] > 0) {
$nids = $this->statisticsStorage
->fetchAll('timestamp', $this->configuration['top_last_num']);
$content['top_last'] = $this->nodeTitleList($nids, $this->t('Last viewed:'));
$content['top_last']['#suffix'] = '<br />';
}
return $content;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.