5

I have made a custom block and i want to make it visible only to pages that follow this pattern: user/[user-id]/galleries.

Is there a way to do it?

2 Answers 2

11

There are Visibility settings for blocks in Drupal. One of options is "Show block on specific pages". Select "Only the listed pages" and input user/*/galleries

1
  • Good point. No need to use PHP.
    – Oswald
    Commented Sep 3, 2011 at 16:55
1

In the Page specific visibility settings, select Show if the following PHP code returns TRUE (PHP-mode, experts only) and enter

return arg(0) === 'user'
    && is_numeric(arg(1))
    && arg(2) === 'galleries'
    && arg(3) === null;

in the Pages text input field. Skip the && arg(3) === null part if you also want to display the block on pages further down in the hierarchy (e.g. on user/[user-id]/galleries/private).

1
  • Although not the best answer for this situation, this is actually a very good tip. Thanks friend! Commented Jan 9, 2012 at 12:47

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.