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?

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

  • Good point. No need to use PHP. – Oswald Sep 3 '11 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).

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

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.