0

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?

1 Answer 1

2

It is looks like you are not using proper class name for extended class.

Ideally, it should be like,

class CommunityControllerGroupCategories extends CommunityControllerGroupCategoriesDefault
{

}

The version which you might be using from above link is an old, we have forked it and improved this in https://github.com/redCOMPONENT-COM/mvcOverride you may try to use it.

Also make sure that you are putting your code at proper place. like code/COMPONENT_NAME/controllers/CONTROLLER_NAME.php

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.