Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

joomla2.5 - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...