alwoodman Posted November 21, 2011 Share Posted November 21, 2011 Hi I am trying to get drupal to only show a block during certain times of the day and only on a specific URI but it keeps showing up on other pages so the substr($_SERVER["REQUEST_URI"], 0) == "/folder/mypage") must be the issue i assume? <?php $time = (int) date('Gi'); return (($time < 600 && $time >= 0000) || ($time > 1630 && $time <= 2359) && substr($_SERVER["REQUEST_URI"], 0) == "/folder/mypage"); ?> <?php $time = (int) date('Gi'); return (($time > 600 && $time < 1630)) && ($_SERVER["REQUEST_URI"] == "/folder/mypage")); ?> thanks Lee Quote Link to comment Share on other sites More sharing options...
haku Posted December 6, 2011 Share Posted December 6, 2011 First off - how are you generating your block - are you creating it through the 'create block' admin interfaced, or are you creating it in a module? Next, you don't use $_SERVER['REQUEST_URI'] in Drupal. This will give you innacurate results, as Drupal paths are all virtual. As such you would use the following: if($_GET['q'] == "folder/mypage"); $_GET['q'] contains the path in Drupal in the non-rewritten version of the URL. note that it doesn't use a leading forward slash. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.