Skip to content

Instantly share code, notes, and snippets.

@rvsjoen
Created July 4, 2012 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvsjoen/3048787 to your computer and use it in GitHub Desktop.
Save rvsjoen/3048787 to your computer and use it in GitHub Desktop.
<?php
class BaseController extends JControllerForm
{
public function delete()
{
// Do shit
$this->setRedirect(JRoute::_($this->getRedirectToList(), false));
}
protected function getRedirectToList()
{
$link = 'index.php?option='.$this->option;
$input = JFactory::getApplication()->input;
if($id = $input->get('Itemid')){
$link .= '&Itemid='.$id;
} else {
$link .= '&view='.$this->view_list;
}
return $link;
}
protected function getRedirectToItem()
{
$link = 'index.php?option='.$this->option.'&view='.$this->view_item;
return $link;
}
}
class ItemController extends BaseController
{
public function task1() // A task that should redirect back to the item view
{
$link = JRoute::_($this->getRedirectToItem().'&id='.$state->get('item.id'), false);
$this->setRedirect($link, $msg);
}
public function task2() // A task that should redirect back to the list view
{
$link = JRoute::_($this->getRedirectToList().$this->getRedirectToListAppend(), false);
$this->setRedirect($link, $msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment