Joomla 1.5 Framework Variable Request | 2008-06-24
In PHP, we have many request hashes: $_GET, $_POST, $_FILES, $_COOKIE and $_REQUEST. (PHP reserved variable start with "$_" ) In Joomla 1.5 Framework, instead of directly using these, we use the the stastic JRequest class. This helps typing less code and improves Joomla security......
For example, we see that the URL is
to get these $_GET session variable, we do
$option = JRequest::getVar('option', 0);
$id = JRequest::getvar('id', 0);
And there is also a set value in Request. This is used when we want to add up something in Request when it is missing. For Example, we want to set request of task editing:
The JRequest of getVar is also very helpful when we are crediting template.
Let say we have a module position that we want to show only in the list index page where its $_GET variable in Request is &page=listindex
Then in the template, we do:
$pageoption = JRequest::getVar( 'page', '' );
if($page != "listindex")
<jdoc:include type="modules" name="postion1" style="xhtml" />
<jdoc:include type="modules" name="right" style="xhtml" /> is defining the module position in template. Remember that if you add a module postion in template page: index.php. You must also add the code in templateDetails.xml: