drupaldrupal-8drupal-blocks

Restrict block visibility by page and content type in Drupal 8


I declared a block to display the 3 most recent articles published and I would like to display it on a specific page so I added /my-page/ into the block page list but it didn't worked. I then changed it to /my-page* and it worked but I ended up getting my block on /my-page/other-content which is not what I wanted.

Moreover if I declare a list of page and a content type, my content type is not taken into account.

Am I doing something wrong ?


Solution

  • Could you first of all simply try /my-page without the trailing slash, please.

    Apart from that you may have a look a the following module:

    Block Exclude pages

    Then you'd say Show for the listed pages

    /my-page*
    !/my-page/*
    

    And regarding the content types there was a bug with ctools which still seems to be unfixed. So you may have a look at:

    Block Visibility Groups

    Here you can configure a visibility group which hides blocks for a specific content type.

    The visibility groups also are reusable, that means you can apply the same settings on multiple blocks.