?
avatar frogydiak
frogydiak
16 Mar 2018

Steps to reproduce the issue

I created a template override for Articles Newsflash module and renamed the default layout to fit my purpose. I refreshed the module settings in the backend and my custom layout does not appear in the layout list. So, I went to ModuleHelper::getLayoutPath() and tried to var_dump() $tPath variable on line# 307 so I would know if my template override path is being checked. Then I get this error:

Class 'Joomla\CMS\Helper\JFactory' not found

On line#294:

$template = \JFactory::getApplication()->getTemplate();

Expected result

Custom layout on template override for module should appear in the Layout list.

Actual result

Error, see above.

System information (as much as possible)

Database Type | mysql
Database Version | 5.5.56-MariaDB
Database Collation | utf8_general_ci
Database Connection Collation | utf8mb4_general_ci
PHP Version | 7.0.27
Web Server | nginx/1.12.2
WebServer to PHP Interface | fpm-fcgi
Joomla! Version | Joomla! 3.8.6 Stable [ Amani ] 13-March-2018 14:00 GMT
Joomla! Platform Version | Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36

Additional comments

avatar frogydiak frogydiak - open - 16 Mar 2018
avatar joomla-cms-bot joomla-cms-bot - change - 16 Mar 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Mar 2018
avatar frogydiak frogydiak - change - 16 Mar 2018
The description was changed
avatar frogydiak frogydiak - edited - 16 Mar 2018
avatar mbabker
mbabker - comment - 16 Mar 2018

Class 'Joomla\CMS\Helper\JFactory' not found

You would only get this error if the CMS was not bootstrapped correctly. The CMS bootstrap loads a class mapping layer for all the classes that were namespaced at 3.8. "JFactory" doesn't exist as a class anymore, but is aliased in that mapping layer, so calls to it will work correctly.

For your issue, the layout not showing up in the backend select lists would mean it's not being found by the form field. The method you're debugging is only involved in the rendering process.

avatar frogydiak
frogydiak - comment - 16 Mar 2018

@mbabker Thanks for replying so soon. When I developed my template, Joomla was version 3.5, I am using the same method of debugging until 3.7.x. Now on 3.8, if you don't mind, how or what is the proper way of bootstrapping the CMS so I don't get an error with class mapping? Can you point me to a documentation please. I am using PhPStorm and I don't remember having a special setting with my IDE environment to have a proper class mapping with Joomla.

Anyways, thanks for pointing me to the form field.

avatar mbabker
mbabker - comment - 16 Mar 2018

For IDEs since 3.8 you should run this stub generator script to generate a list of class stubs for the renamed classes. If PHP is actually being executed somehow, the various scripts in the CLI directory have a minimalistic bootstrap to ensure everything is usable.

avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Mar 2018
Status New Discussion
avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Mar 2018
Category Code style
avatar joomla-cms-bot joomla-cms-bot - change - 21 Mar 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-03-21 14:42:14
Closed_By joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 21 Mar 2018
avatar Quy Quy - change - 21 Mar 2018
Closed_Date 2018-03-21 14:42:14 2018-03-21 14:42:16
Closed_By joomla-cms-bot Quy
avatar joomla-cms-bot
joomla-cms-bot - comment - 21 Mar 2018

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19927

Add a Comment

Login with GitHub to post a comment