I tried to edit some of the core files in Joomla. Im using MVC override plugin:enter link description here

I want to override article.php and articles.php in components/com_content/models.

The override is done and is now working. My problem is that i get this error on my frontpage/homepage.

Fatal error: Cannot redeclare class ContentModelArticles in /Applications/MAMP/htdocs/site/components/com_content/models/articles.php on line 680

Thats the only place i get that error. In articles.php and other places, there are no sign of any similar errors. Can anyone pleas tell me what the solution would be?

Im not sure how to do the override. i just copied the articles.php and put it inside another folder in my templates file. so everything is the same except I added some more fields to my articles.php. It starts like this:

defined('_JEXEC') or die;

use Joomla\Registry\Registry;

 * This models supports retrieving lists of articles.
 * @since  1.6
class ContentModelArticles extends JModelList
     * Constructor.
     * @param   array  $config  An optional associative array of configuration settings.
     * @see     JController
     * @since   1.6
    public function __construct($config = array())
        if (empty($config['filter_fields']))

Im not sure what to do. If I change the ContentModelsArticles to something else.

  • I tried to edit some of the core files in Joomla >> why? If you want to override anything in Joomla's core, please develop a plugin to extend the class you'd like to override. Editing core file will cause potential problems for you and will be lost in future Joomla updates
    – Lodder
    Commented Oct 22, 2015 at 8:54
  • Hello Lodder. Im using a joomla plugin(didn't develop it myself) but it does the same. MVC override(which i linked to), allows you to use another articles.php / any other joomla class. in my case i have mine in site/Templates/mytemplate/code/com_content/models/articles.php. But my problem is im not sure if i have to change anything in the class name? (the code above)?
    – Peter
    Commented Oct 22, 2015 at 8:59
  • can anyone pleas help me? im really stuck right now and dont know how to override articles.php
    – Peter
    Commented Oct 24, 2015 at 8:12
  • You are duplicating it so not overriding it. You need to extend this class so: class ContentModelArticles extends JModelList {. Becomes. Class CustomContentModelArticles extends ContentModelArticles { Commented Nov 14, 2015 at 0:13

2 Answers 2


Overrides do not usually re-declare classes. In most cases, an override is a file loaded instead of the original. Understanding Output Overrides

Given said that, there is an advanced technique to declare a system plugin and load a new class before the original class. Then, Joomla class loader will no load the original class. Overriding a plugin's non-templated layout files?

  • please can you show some code example for better understanding. I understood the concept but facing similar issue. I am trying to override a helper file of a custom component by developing a system plugin.
    – Liz.
    Commented Jun 2, 2016 at 11:39
  • This is a nice example: How to override the component mvc from the Joomla! core docs.joomla.org/…
    – Anibal
    Commented Jun 3, 2016 at 12:37
  • I tried this but I am getting an error cannot redeclare the class MailtoController . I also checked with some other component and I get this same error for helper file as well. But yes the code works in case of content controller. Can you guide me how to make it work for other components as well
    – Liz.
    Commented Jun 3, 2016 at 12:59
  • The only tip is to be 100% sure that it loads before the original class. If you load it after the original class, then you get the error about redeclaration.
    – Anibal
    Commented Jun 4, 2016 at 13:55

You've got it right. In: site/templates/mytemplate/code/com_content/models/articles.php

You should have the class created like:

class ContentModelArticles extends ContentModelArticlesDefault

Baiscally the plugin load the "original class" into a string actually creating it through eval(), with Default added to it.

Your Answer

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

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