Does anyone know a way to test which page (URL) a user is currently on? I want to test for viewing a certain page and then add a menu item if that condition is true or remove a menu item if that condition is false. Thanks if anyone knows an API function or PHP code that can return the current page being viewed. Aly
In the site.php file you can use a variable (named as you wish) to return the current page's full hyperlink URL, in this example the variable is named $userlink PHP: $userlink = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //Return current hyperlink of page being rendered Here is an example of testing you can do using this information, to find all pages that have 'helpdesk' in their URL, what you then do from their with this information is up to you. PHP: $userlink = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //Return current hyperlink of page being rendered$helpdesk = 'helpdesk'; //Set variable value$helpdeskexists = strpos($userlink, $helpdesk); //Search for presence of value 'helpdesk' in current page hyperlink
Other useful methods: PHP: Am_Di::getInstance()->request->getModuleName(); // amember module name, for example 'default'Am_Di::getInstance()->request->getControllerName(); // amember controller name, for example 'member'Am_Di::getInstance()->request->getActionName(); // action name, for example 'index'Am_Di::getInstance()->request->getParam('xx'); // if url ends with ?xx=22, will return 22