redCOMPONENT-COM / mvcOverride

Joomla System Plugin that allows overriding any class in Joomla, see: http://redcomponent-com.github.io/redCORE/?chapters/mvcoverride/overview.md
6 stars 17 forks source link

Override of administrator classes doesn't work wen used from the frontend #20

Open liviuk2 opened 8 years ago

liviuk2 commented 8 years ago

Hi, I noticed that when a class from the backend has an override (so located in administrator/code) and that class is used from the frontend the override is not loaded so it is not effective.

I think the problem is here, because it is trying to get the original file from the front end (without the string "/administrator" in the path), obviously it's not finding anything so the override isn't loaded.

I think a possible solution could be replacing the highlithed row with this code:

$adminInPath = "";
// If i'm using a file from administrator with an override and I'm in the frontend
// I should ad "/administrator" before "/components" in the $realPath
if (strpos($includePath,"administrator") !== FALSE && strpos(JPATH_BASE,"administrator") === FALSE)
{
    $adminInPath= "/administrator";
}
$realPath = JPATH_BASE . $adminInPath . '/components/' . substr($filePath, strlen($includePath));

Let me know if I'm right or I'm using the plugin in the wrong way. Thanks for your attention!

cacastego commented 3 years ago

Hi, im trying to override a model in administrator / component but it doesnt work. Can someone help.

My override route is: administrator/code/com_example/model/my_override.php