Joomla Asked by Aymeric KEYEWA on August 17, 2020

I have an issue with a cli php script that I’m trying to execute.
I want to add an article with custom fields.

The part where I add articles is working well, but when I add the code to load the article I just stored and set its custom fields values, there is the following error:

Call to undefined method AddArticle::getTemplate(): JLIB_APPLICATION_ERROR_INVALID_CONTROLLER

The error seems to be related to the following line:

$article_joom = JControllerLegacy::getInstance('Content')->getModel('Article')->getItem($article['id']);

I’ve tried to load the ContentLoader class because someone said it would help, but it didn’t really change anything.

From what I’ve seen, I may not be able to use the JController on a cli script, but I haven’t found another way to load articles.

One Answer

Start by updating to the latest version of Joomla - 3.9.20 - if you're able to first.

A number of changes regarding JControllerLegacy were made in Joomla 3.8 (see and so that is certainly worth investigating first.

Next take a look at this post which relates to calling JController from CLI Call Controller's Publish-Method from CLI or Helper

Answered by Patrick Jackson on August 17, 2020

Add your own answers!

Related Questions

Generating a module instance from PHP

0  Asked on September 5, 2021 by ffrewin


Embed custom JS app in Joomla MVC

0  Asked on September 5, 2021 by miasto


Error when updating Gantry from 4.1.20 to 4.1.32

1  Asked on September 5, 2021 by norberto-gomes


Change user permissions programmatically on the fly

1  Asked on September 5, 2021 by aheavyobject


Akeeba backup update broke the site

2  Asked on September 5, 2021 by hamlet-kraskian


Proper way for autoloading in Joomla 4

1  Asked on September 5, 2021 by webchun


Menu Specifically For Super Users

1  Asked on September 5, 2021


Joomla PHP does not match host PHP

2  Asked on February 18, 2021


Controller Joomla – Output Class construct for color css style

1  Asked on February 5, 2021 by andrea-suriani


Joomla custom component – router not find alias

1  Asked on January 21, 2021 by lecraver


Joomla 3 call model function inside controller

3  Asked on December 28, 2020 by wbdevlop


Product url problem after updating VirtueMart

1  Asked on December 23, 2020 by kiasaty


Display intro image inside mod_breadcrumbs

0  Asked on November 11, 2020 by geoplous


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP