Last Updated: February 25, 2016
·
1.601K
· teknonono

Passing parameters in Joomla 3.x

View to Controller

views/foo/tmpl.form.php

<input type="hidden" name="Itemid" value="<?php echo $itemid; ?>" />
<input type="hidden" name="id" value="<?php echo $id; ?>" /> 

controllers/foo.php

public function save(){
     $app = JFactory::getApplication();
     $itemid = $app->input->getInt('Itemid');
     $id = $app->input->getInt('id');
      ......
    $link = "....Itemid={$itemid}"; // 'I' must be capital, which is weird....XD 
    $this->setRedirect($link,"Redirecting...");

   }

URL to Model

using JInput:

public function getSome(){
$jinput = JFactory::getApplication()->input;
$itemid = $jinput->getInt('itemid', 0 );   
$id = $jinput->getInt('id', 0 );
    }