TransWikia.com

Proper way for autoloading in Joomla 4

Joomla Asked by webchun on September 5, 2021

I’m trying to make my news module modification working with Joomla 4. My module is calling custom fields and I use this autoloader below to make it work in Joomla 4. Can you tell me what is the proper way to use autoloader on Joomla 4 instead of using this legacy one?

JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

One Answer

This should still work in 4.0 but will break in 5.0. You are advised to use fully qualified class names. Remove JLoader::register() call and instead add a use statement:

use JoomlaComponentFieldsAdministratorHelperFieldsHelper;

Correct answer by Sharky on September 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP