Joomla forwarding code to the View...is this the correct way to do it?
Posted
by jax
on Stack Overflow
See other posts from Stack Overflow
or by jax
Published on 2010-06-17T12:08:38Z
Indexed on
2010/06/17
12:13 UTC
Read the original article
Hit count: 200
joomla
Here are some sample methods from my Controller
class. Now when the user clicks the New button $task=add is sent to the Controller and the add() method is called. As you can see it does not really do anything, it just creates a url and forwards it off to the correct view. Is this the correct way of doing things in the MVC pattern?
/**
* New button was pressed
*/
function add() {
$link = JRoute::_('index.php?option=com_myapp&c=apps&view=editapp&cid[]=', false);
$this->setRedirect($link);
}
/**
* Edit button was pressed - just use the first selection for editing
*/
function edit() {
$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
$id = $cid[0];
$link = JRoute::_("index.php?option=com_myapp&c=apps&view=editapp&cid[]=$id", false);
$this->setRedirect($link);
}
© Stack Overflow or respective owner