Joomla 2.5 - the use of administrators component controllers in front of the component

how can i use controllers created in

/administrator/components/com_mycom/controllers/* 

in

 /components/com_mycom/mycom.php 

More details:

I have a "log" controller with the add method, and I would like to use it from the interface. I have not logged in to the backend, the task is not completed, and the 500 error goes up. Therefore, I would just like to include the backend controllerpath in the interface, so JController::getInstance( 'Mycom' ) still works.

Hello...

EDIT:

After a long search, I could find a more or less undocumented parameter: JController::getInstance() , and the second: $config = array() . Looking through the source code, I found that there is one key of the "configuration array" of interest to us: "base_path".

Call:

 JController:getInstance( 'Mycom, array('base_path' =>JPATH_ADMINISTRATOR.DS.'components'.DS.'com_mycom')' ); 

the backend controller always delivers, and you can safely use it in the external interface of the BUT , so you should make sure that the views are then shot from the inside of the component. In my case, I just use it to create ajax calls, so it doesn't matter, but you need to be careful using this method when planning to create "frontend views" using the "backend controller".

Hello...

+4
source share
1 answer

I recently had a similar problem when I wanted to use all the back code of the CRUD system in the interface.

This is the method that worked for me (and I am not saying that it is recommended or recommended):

I just modeled the folder / file structure from the backend. PHP files contained something like:

require_once JPATH_ADMINISTRATOR . '/components/com_mycom/controllers/log.php';

+1
source

Source: https://habr.com/ru/post/1446786/


All Articles