From the Drupal 8 administration, I configured a block (block created from a custom module) for display it in /user/* pages.

enter image description here

It works; I see this block in /user/* and /user/*/edit pages. Now, I want to display my block only from /user/* pages (the view mode), not from /user/*/edit pages (the edit mode).

Can I do that from the Drupal Administration page? I tested it adding "!/user/*/edit" but this has no effect.

enter image description here

If I can't, how can I do that from my custom module?

  • Try using /user/*/view instead.
    – Eyal
    Oct 22 '16 at 0:15
  • Not work ;) with "/user/*/view", the block not showed from /user/4 or /user/4/edit by example Oct 22 '16 at 0:24
  • It could be that this condition plugin is too simple for your use case. Fortunately it is fairly easy to create a custom condition plugin in drupal 8.
    – Eyal
    Oct 22 '16 at 0:28
  • I think too..what is a good way for manage this case from a custom module ? The block is already defined from my custom module in a Block Class Oct 22 '16 at 0:32
  • 1
    You can write your own condition plugin class. It has a method that returns true if the block should be visible.
    – Eyal
    Oct 22 '16 at 7:55

If you use this module then the exclamation prefix would work to exclude paths: https://www.drupal.org/project/block_exclude_pages


For Drupal 8 install the Route Condition Module and use the entity.user.canonical condition.


For drupal 7 users you can use Context module and simple add page to path /user/* and ~/user/*/edit/ to exclude edit page.


If it's your own custom block plugin, you can have your build function return null on node edit pages.


There is a module called Route Condition that allows you to specify exact routes (pages) to display blocks on. So for the user profile page the route would be user.entity.canonical (which is actually the example on the module page.


Why don't you try just to hide on the pages you don't want it to be displayed instead of using "Show for the listed pages"? Change the option with "Hide for the listed pages" and add there user/*/edit and every other page where you don't want that block to be displayed.

  • and every other page: that would be a lot of pages!
    – daniels
    May 16 '17 at 15:55

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.