Submitted by Kiran on Thu, 04/09/2009 - 08:36
Inside the block admini interface, one can enter PHP code snippets in “Page visibility settings” section of the block configuration page.
While a page being generated, Drupal will run the PHP snippet to determine whether a block will be displayed.
Examples of some of the most common snippets follow; each snippet should return TRUE or FALSE to indicate whether the block should be visible for that particular request.
Displaying a Block to Logged-In Users Only
Only return TRUE when $user->id is not 0.
<?php global $user; return (bool) $user->uid; ?>
Displaying a Block to Anonymous Users Only
Only return TRUE when $user->uid is 0.
<?php global $user; return !(bool) $user->uid; ?>
»
- Kiran's blog
- 228 reads













Post new comment