How to pass variables or parameters from one Joomla article to another using DirectPHP? |
| Written by kksou | ||
| Thursday, 30 June 2011 | ||
|
One of the most commonly asked questions for DirectPHP is: how do you pass a variable or parameter from one Joomla page to another? In a plain PHP page, you can easily do this with: page1.php?var1=value1 But try this in a Joomla article using DirectPHP. Most likely you will be directed somewhere else and your article will not appear.
DemoLet's see a quick demo of this in action first.
var1 = The codes that produce the above are: <?php echo "var1 = ".$_GET['var1']."<br />"; echo "var2 = ".$_GET['var2']."<br />"; ?> Now click on this link which contains: http://www.kksou.com/php-gtk2/index.php?option=com_content&Itemid=1&id=2013&lang=en&task=view&var1=value1&var2=value2 Did you see that the two parameters above have been populated with 'value1' and 'value2' respectively? ExplanationIf you take a look at the URL of your Joomla articles, you should see that each article is identified by 4 key parameters:
For this article that you are viewing right now, you can see that the 4 values are:
If you are using languages other than English, you might also need to pass in the parameter lang. ConclusionTo pass variables or parameters from one Joomla article to another, in addition to the parameters you want to pass, you must also remember to pass in the following variables:
For example: http://www.kksou.com/php-gtk2/index.php?option=com_content&Itemid=1&id=2013&lang=en&task=view&var1=value1&var2=value2 |
||
| < Prev | Next > |
|---|




