I would like to set up a default view. If my component gets called by using administrator/index.php?option=com_bestia&view=
I'm getting the error:
404 View not found [Name, Typ, Präfix]: bestia, html, bestiaView
com_banners does it better:
administrator/index.php?option=com_banners&view=
results in showing the first page of banners component.
This is my controller:
class BestiaController extends JControllerLegacy
{
protected $default_view = 'cpanel';
/**
* display function.
*
* @access public
* @param bool $cachable (default: false)
* @param bool $urlparams (default: false)
* @return void
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/bestia.php';
$view = $this->input->get('view', 'cpanel');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($layout == 'edit' && !$this->checkEditId('com_bestia.edit.'.$view, $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_bestia&view='.$view.'s', false));
return false;
}
parent::display($cachable, $urlparams);
return $this;
}
}