Show blocks on other Users account pages only?

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by Rick Wagner on April 20, 2011 at 5:21pm

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?

Categories: , ,

Comments

Try this - use PHP mode for

Posted by rich.yumul on April 20, 2011 at 5:32pm

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?

Posted by Rick Wagner on April 20, 2011 at 6:00pm

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.

Posted by rich.yumul on April 20, 2011 at 6:20pm

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?

Posted by kscheirer on April 20, 2011 at 8:24pm

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

Posted by senpai on April 20, 2011 at 9:06pm

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

Posted by Rick Wagner on April 21, 2011 at 7:51pm

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

Posted by sj.suraj on February 10, 2017 at 11:23am

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:

AltStyle によって変換されたページ (->オリジナル) /