I am trying to override an administrator component controller class in jomsocial for the purpose of adding an extra field in category edit option and to save it in db.
According to this documentation, created a community plugin.
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
jimport( 'joomla.plugin.plugin' );
require_once( JPATH_SITE .'/administrator/components/com_community/libraries/core.php');
require_once( JPATH_SITE .'/administrator/components/com_community/controllers/groupcategories.php');
class plgCommunityMygroupcategories extends JPlugin {
function __construct(& $subject, $config){
parent::__construct($subject, $config);
$app = JFactory::getApplication();
if('com_community' == JRequest::getCMD('option') && $app->isAdmin()) {
require_once($_SERVER['DOCUMENT_ROOT']. '/folder_path/dev/web/administrator/components/com_community/controllers/mygroupcategories.php');
}
}
In the new controller, I try to extend the main group controller
class CommunityControllerMyGroupCategories extends CommunityControllerGroupCategories
{
}
The admin controller 'groupcategories' is loaded by using the name of the view.
THe default url is looks like this, <some_url>/web/administrator/index.php?option=com_community&view=groupcategories
Is it the right way to do this? In this blog, it is explained the way to override group controller, but it is not an administrator controller. There is a trigger event ' onBeforeControllerCreate' which can be used to override the class via plugin. But how can I do this if it is a administrator controller as mentioned above? What is the best method to handle this?