How would I go about displaying a block on all pages with the url that ends with "/thenameofmypage" or anything that begins with "/thenameofmypage?"

I basicaly want to display the block on the search page and the results page.

I was thinking of something along the lines of this, but not sure about the search results part (with the ?+ at the end)

$match = FALSE;
if (substr($_SERVER["REQUEST_URI"], 0, 10) == '/thenameofmypage')
{ $match = TRUE;}
return $match;

Comments

ludo1960’s picture

On the Block configuration page choose "Show block on specific pages: " and just list the pages to show the block on. e.g. "Example paths are blog for the blog page and blog/* for every personal blog."

new123456789’s picture

Thanks for that!

I just realised that even just

Show block on specific pages:
nameofmypage

Works, I just didn't notice it because my blocks weren't displaying correctly and all sorts of other issues :(

http://drupal.org/node/1889770

billdawson’s picture

Show on specific page does not work on 'user'.

It will work if you add a wildcard ('*') but then it shows on all pages beginning with 'user'. This is not the desired result.

I want my block to only show on:

user
user/edit

I do not want it to show on

user/someotherusername