2

I am looking to show a certain block on a page only when a certain url attribute (using alias)

For example:

I have pages /foo/*

I want to show the The block when viewing /foo/*?showblock

Where * is a wildcard.

I have tried typing this into my "Show block on specific pages" portion of the block settings, but the block never shows. Any ideas? Thanks!

2

You can use PHP visibility on your block settings to achieve this. Drupal block's visibility does not provide the functionality to display blocks based on parameters after ? (aside from ?q= of course) so you need to do this with custom PHP.

Set your block visibility to use PHP as the markup and place this in your code:

<?php 
// Show the block if the 'showblock' attribute is available
if (!empty($_GET['showblock'])) {
  return TRUE;
}
return FALSE;

?>

Happy Programming!

2

It's definitely worth looking at the Context module. This should help you no-end with problems like this.

That said, TheRealWebGuy has a better answer if this is just a one-off, but it's always better to know these things :-)

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.