0

I'm using the drupal administrator menu for the settings there i have a page called /desert/234234 the block should appear only when the url is /desert/(desert_id) how can i restrict that

4 Answers 4

3

In Drupal 7 you can use PHP code in the block's "Visibility settings."

Steps

  • Go to admin/modules and enable the PHP filter module

    enter image description here

  • Go to admin/structure/block and click on "Configure"

    enter image description here

    • Enter the following PHP code (including <?php and ?>) in the Page settings.

    enter image description here

1

on visibility settings, choose two mode of visibility, for example:

  • type of content, choose one content type you want your block to show on
  • on page visibility, you choose hide for listed page, the type /desert/*/*
1
  • This is valid for Drupal 8, 9 & 10. Be sure to add the URL to "Pages" not "Route".
    – Jono
    Commented Jul 10, 2023 at 9:06
0

Drupal 7: 1. Go to: /admin/structure/block 2. Click configure 3. In Visibility settings set "Only the listed pages" and in textarea below insert " /desert/* .

Also remember to activate block - put it in one of regions of the page.

4
  • i can do if it is a static page like desert/xxxxx but my url is desert/id. here id is an dynamic content
    – Ajmal
    Commented Aug 13, 2013 at 8:38
  • Wildcard () replaces all characters. So url like /desert/ is equal to /desert/123456, /desert/abcdef, /desert/cake/apple and so on.
    – majkelch
    Commented Aug 13, 2013 at 8:59
  • let me explain in clear. i'm having two pages desert/(13221)dynamic value and desert/continent. The block should not display in desert/continent page. how can i restrict?
    – Ajmal
    Commented Aug 13, 2013 at 12:16
  • Then in the same tab you should switch to "Pages on which this PHP code returns TRUE (experts only)" and write some PHP Read this for more help on this topic. Or you can write your custom module and use hook_block_info_alter.
    – majkelch
    Commented Aug 13, 2013 at 12:45
0

Make a block appear only when URL is something: On the configuration page of the block go to Visibility settings -> Pages -> Show block on specific pages, and select "Only the listed pages." Wildcards may be used if needed; for example, desert/* would match any path starting with desert/.

1
  • i can do if it is a static page like desert/xxxxx but my url is desert/id. here id is an dynamic content
    – Ajmal
    Commented Aug 13, 2013 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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