PCinvent.info

PCinvent Studio Template

Jun 24 2008
Joomla 1.5 Framework Variable Request Print E-mail
Tuesday, 24 June 2008


Read More Articles in: Technology>>>Programming

This Article is written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it


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

index.php&option=com_content&id=3

to  get these $_GET session variable, we do

$option = JRequest::getVar('option', 0);

$id = JRequest::getvar('id', 0);

echo $option;

echo $id;

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:

JRequest::setVar('task', 'edit');

 

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:

<?php
$pageoption = JRequest::getVar( 'page', '' );
if($page != "listindex")
{
?>
    <jdoc:include type="modules" name="postion1" style="xhtml" />
<?php
}
?>

 <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:

<positions>
    <position>postion1</position>
</positions>

 

Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

busy
Tags:  Technology Programming Joomla 1.5 Framework Variable Request JRequest JRequest:getVar JRequest:setVar
Last Updated ( Thursday, 26 June 2008 )
 
< Prev   Next >
Site by PCinvent.com