I am new to php and trying to return true / false based upon the user url. (Using this in drupal)
So for example if the user is at:
http://www.example.com/training I want it to return true
http://www.example.com/training/home I want it to return true
http://www.example.com/browse/training/results/* I want it to return true
For anything else though I want it false.
http://www.example.com/training/backpacking I want it to return false.
My first ever php script has a bug…go figure. Anyway it doesn’t show on anything that is not under training but it does show on training sub areas where it is not desired.
global $language;
$curr_uri = check_plain(request_uri());
if ($language->language == 'en')
if (basename(dirname($curr_uri)) == 'training')
return TRUE;
else
return FALSE;
else
return FALSE;
I understand the concept of what needs to be accomplished. I want to check for three specific uri’s and not show on anything else. I also tried:
global $language;
$curr_uri = check_plain(request_uri());
if ($language->language == 'en')
if ($curr_uri == '/training/home')
return TRUE;
else
return FALSE;
else
return FALSE;
Adnan…I’m not sure what your edit was but I found a typo and it is working now with this code:
<?php
global $language;
$curr_uri = check_plain(request_uri());
if ( $language->language == 'en')
if($curr_uri == '/training/home' || $curr_uri == '/browse/training/results' )
return TRUE;
else
return FALSE;
else
return FALSE;
?>
1 Answer