Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding Joomla core component file

I am trying to override the com_content/views/article/view.html.php file in joomla using the instructions given in this page

It says I have to create a folder named 'code' in base directory and create the same directory structure. I tried it , but its not working. Can someone confirm whether its working.

Where should I create code folder? Is it on root of joomla installations?

PS- The edit is working correctly when applied on core file

like image 860
Ajith Avatar asked Dec 07 '12 12:12

Ajith


1 Answers

You can override (nearly) any class in Joomla, if your class with the same name is loaded first. To ensure that, you need to create a system plugin.

Here is an example for root/components/com_content/views/article/view.html.php:

class plgSystemOverride extends JPlugin
{
    public function onAfterRoute()
    {
        JLoader::register('ContentViewArticle', 'path/to/override.php', true);
    } 
}

CAVEAT: Overriding a core class can lead to problems with other extensions, if you're not very careful. For views, though, any interferrence with other extensions is less likely.

like image 66
nibra Avatar answered Oct 22 '22 19:10

nibra