[development] Block php snippet not failing

Jeff Greenberg jeff at ayendesigns.com
Sat Oct 31 21:47:29 UTC 2009

In D6, I have the page url of mypage.com/catalog/16?page=0%2C1

I have the following snipped in the pages section of a block, with the 
PHP snippet option chosen:

if ($_GET['q']) {
   $my_drupal_path = $_GET['q'];
} else { $my_drupal_path = substr($_SERVER['REQUEST_URI'], 1);

if ( stristr($my_drupal_path, 'catalog/16?page=0%2C0') ||
     ((stristr($my_drupal_path, 'catalog/16')) && 
(stristr($my_drupal_path, 'catalog/16?page')===false))
   ) return true;
else return false;

So the idea is that it will be TRUE for /catalog/16  and for 
/catalog/16?page=02C0  but not for page=02C1 or greater

When I put the three parts of the if statement (separating both sides of 
the && into two statements) in a separate php file and test each, based 
on the given URL, the result is FALSE, TRUE, FALSE, which is what it 
should be.

That said, the block continues to show on every page. If I force it to 
FALSE (comment the IF and just leave return false) the block does not 
show. I need another pair of eyes...mine are crossed at this point.

More information about the development mailing list