Is it possible to display a block only on a URL without any parameters? E.g. on:

  • my.site.org/search

but not on:

  • my.site.org/search?q=term

When I configure a block ('/admin/structure/block/manage/myblock') and set visibility for pages at: '/search' (see the picture), then the block is displayed on the page '/search?q=term' as well.

enter image description here


You can use condition_query it will give you an extra box where you can put query parameters like q=term

enter image description here

  • Thanks @GiorgosK. I hoped, that it is possible without an additional module. I need it in a project, where are allowed only modules, which are covered by the Drupal security advisory policy. So it looks like I have to find a workaround. E.g. the search results can be displayed on some other URL, like: search/results?q=term – Antonín Slejška Feb 26 '18 at 9:36
  • well its either this or create your own implementation in a module or your theme. why would your implementation be more secure than a module already used by more than 186 sites? – GiorgosK Feb 26 '18 at 9:41
  • Generally there is at the moment too much custom code in the project. So for unimportant functionality it is not recommended to add new code. But your solution can be quite usefull for other projects. – Antonín Slejška Feb 26 '18 at 9:56

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.