class PageTitleBlock

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php \Drupal\Core\Block\Plugin\Block\PageTitleBlock
  2. 9 core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php \Drupal\Core\Block\Plugin\Block\PageTitleBlock
  3. 8.9.x core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php \Drupal\Core\Block\Plugin\Block\PageTitleBlock

Provides a block to display the page title.

Attributes

#[Block(id: "page_title_block", admin_label: new TranslatableMarkup("Page title"), forms: [ 'settings_tray' => FALSE, ])]

Hierarchy

Expanded class hierarchy of PageTitleBlock

File

core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php, line 13

Namespace

Drupal\Core\Block\Plugin\Block
View source
class PageTitleBlock extends BlockBase implements TitleBlockPluginInterface {
  
  /**
   * The page title: a string (plain title) or a render array (formatted title).
   *
   * @var string|array
   */
  protected $title = '';
  
  /**
   * {@inheritdoc}
   */
  public function setTitle($title) {
    $this->title = $title;
    return $this;
  }
  
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'label_display' => FALSE,
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#type' => 'page_title',
      '#title' => $this->title,
    ];
  }

}

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