我一直在尝试学习如何构建 Joomla 组件。
我一直在使用http://joomlaprogrammingbook.com/这本书很棒。我现在可以毫无问题地做插件和模块。但是,我对如何为组件加载某些控制器感到困惑。如果需要,给出的站点有完整的代码。
加载的初始控制器是:
class JoomproSubsController extends JController
{
/**
* @var string The default view.
* @since 1.6
*/
protected $default_view = 'submanager';
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*/
public function display($cachable = false, $urlparams = false)
{
JLoader::register('JoomproSubsHelper', JPATH_COMPONENT.'/helpers/joomprosubs.php');
// Load the submenu.
JoomproSubsHelper::addSubmenu(JRequest::getCmd('view', 'submanager'));
$view = JRequest::getCmd('view', 'submanager');
$layout = JRequest::getCmd('layout', 'default');
$id = JRequest::getInt('id');
// Check for edit form.
if ($view == 'subscription' && $layout == 'edit' && !$this->checkEditId('com_joomprosubs.edit.subscription', $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_joomprosubs&view=submanager', false));
return false;
}
parent::display();
return $this;
}
}
我可以看到它是如何以及何时加载的。然而,在某些时候,它似乎也加载了class JoomproSubsControllerSubManager extends JControllerAdmin
现在我虽然要做到这一点,它需要一个 url,其中包括com_joomproSubs?task=submanager
但这不存在。所以我的问题是这怎么会发生?