ActiveTopicsBlock.php

Same filename in other branches
  1. 8.9.x core/modules/forum/src/Plugin/Block/ActiveTopicsBlock.php
  2. 10 core/modules/forum/src/Plugin/Block/ActiveTopicsBlock.php
  3. 11.x core/modules/forum/src/Plugin/Block/ActiveTopicsBlock.php

Namespace

Drupal\forum\Plugin\Block

File

core/modules/forum/src/Plugin/Block/ActiveTopicsBlock.php

View source
<?php

namespace Drupal\forum\Plugin\Block;

use Drupal\Core\Database\Database;

/**
 * Provides an 'Active forum topics' block.
 *
 * @Block(
 *   id = "forum_active_block",
 *   admin_label = @Translation("Active forum topics"),
 *   category = @Translation("Lists (Views)")
 * )
 */
class ActiveTopicsBlock extends ForumBlockBase {
    
    /**
     * {@inheritdoc}
     */
    protected function buildForumQuery() {
        return Database::getConnection()->select('forum_index', 'f')
            ->fields('f')
            ->addTag('node_access')
            ->addMetaData('base_table', 'forum_index')
            ->orderBy('f.last_comment_timestamp', 'DESC')
            ->range(0, $this->configuration['block_count']);
    }

}

Classes

Title Deprecated Summary
ActiveTopicsBlock Provides an 'Active forum topics' block.

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