Show blocks on other Users account pages only?

Events happening in the community are now at Drupal community events on www.drupal.org.
Rick Wagner's picture

I've found a handy code snippet to show a block on the logged in Users My Account page (/user) but also need to show certain blocks on other User's account pages (users/sampleuser)

Using the wildcard "users/*" in the block config also adds the block to "/user", which I don't want.

Is there a code snippet that will do what I want? Show blocks on other Users pages only?

Comments

Try this - use PHP mode for

rich.yumul's picture

Try this - use PHP mode for block visibility and

<?php
return eregi('/user/.*', $_SERVER['REQUEST_URI']);
?>

Rich Yumul
Sage Tree Solutions
www.sagetree.net

re: Show blocks on other Users account pages only?

Rick Wagner's picture

Not seeing the block on any page with this. Doesn't the PHP code need to return a TRUE or FALSE?

Unless we're taliking about something other than: Block configure / Page Specific Visiblity Settings

X Show if the following PHP code returns TRUE (PHP-mode, experts only).

Guess I'm dating my self.

rich.yumul's picture

I checked the php docs & eregi was deprecated. Maybe try this:

<?php
return preg_match('/\/user\/.*/', $_SERVER['REQUEST_URI']);
?>

Rich Yumul
Sage Tree Solutions
www.sagetree.net

are you sure?

kscheirer's picture

users/* should never match the url http://example.com/user!

In fact, I've always had to enter 2 paths when I want my blocks to show up on both, I'll typically use

user
user/*

Whats the handy code snippet you're using? Rich's example should work, I hate putting php in block assignments if its avoidable though.

Check out the Me Aliases and Context modules

senpai's picture

In addition to Karl's suggestions, you should look at the Me Aliases and Context modules which will probably get you 100% of what you need and be standards-compliant too.


Joel Farris | my 'certified to rock' score
Transparatech
http://transparatech.com
619.717.2805

Working now with Joel's suggestion

Rick Wagner's picture

Was still getting blocks set to "users/*" only on the logged in Users "My Account" page even on a brand new Drupal 6 install.

At any rate, the 'me aliases' Module was just what I needed to wrangle all the block visibility required for this site, and I owe Senpai a drink for the suggestion.

How to show blocks on user profile page

sj.suraj's picture

How can i show a block only on the user profile page.

San Diego DUG

Group categories

Event Classifications

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: