How to Show Block in PHP-Mode on Your Drupal-Based Site
This article is for experienced developers who are close with PHP. It would tell you a little trick of how one can show his block if PHP code returns TRUE. Let’s begin!
So, first navigate to the Blocks area. Please select Administer > Site building > Blocks from admin navigation menu:
Then select the block you wish to deal with. Let’s work with, for example, standard User login block. In the list of blocks, set region (place the block will be allocated in) from the appropriate drop-down list within the Region column:
Then click configure link. You will be immediately navigated to the ‘User login’ block details. Set the required parameters if necessary and scroll the page down until Page specific visibility settings:
Within this area, click Show if the following PHP code returns TRUE (PHP-mode, experts only) radio button and place the code into the Pages text area. The code may be:
<?php if($a == $b) return true; ?>
In this case, the block will be shown once $a == $b.
Please be sure that the code is between <?php ?>. Also note that executing incorrect PHP-code can break your Drupal site.
We’re almost there! Click Save block to save your changes.
Done!