0

I defined a custom route in a custom module:

mymodule.overviewpage:
  path: '/mymodule-overview'
  defaults:
    _controller: '\Drupal\mymodule\Controller\PageOverviewController::content'
    _title: 'Overview'
  requirements:
    _permission: 'access content'

Here is the controller:

class PageOverviewController  extends ControllerBase {
  public function content() {
    return array(
      '#markup' => 'hello'
    );
  }

}

This route is working fine, I see the "hello" text when entering this path in my project but I do not see the page title. The page title "Overview" is used in the title tag in head of the HTML page but there is no page title block - it is not even rendered. Changing to Bartik theme I see the page title "Overview".

I know found out that the visibility of this block was set: there was a checkbox checked which defined the block to be hidden when on a node page of a special content type/ node bundle: enter image description here

My question: why is the page title block not visible on panel or view generated pages or on custom routes? What should I add to avoid such a behavior? Is there a way to hide the block for special contenty types without hiding it elsewhere?

4

Because they are not a page of that node type. This filter doesn't just apply to node/*, it applies to all pages. And if there is no node object, the condition will always be false.

If you need something that is true on all non-node pages but for node pages only for a specific ype, you need to define your own condition plugin or use hook_block_access().

  • 1
    That is WOEFULLY not documented in the blocks ui. It is implicit from that (to me) that page title would be displayed everywhere, but where page types are concerned, only on the ones selected. If not, there needs to be a document on that - and a negate condition. – NikLP Mar 22 '17 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.