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!

Related Questions

Add field to menu settings to output open graph image

1  Asked on December 30, 2021 by mano-meter


Edited css not updated in XAMPP

1  Asked on December 9, 2021 by advait-varma


Update from 3.9.x to 4.x

2  Asked on November 27, 2021 by lovntola


Other files overriding my template css with bootstrap?

1  Asked on November 19, 2021 by matthiasdunkel


Javascript accordion with anchors for joomla

1  Asked on November 5, 2021 by fruit_alchemist


Cannot Connect To MSSQL Server

3  Asked on September 5, 2021 by jamesmandatory


PlotALOT RSForm Query showing only one result

1  Asked on September 5, 2021 by gart


Getting module parameters in AJAX call using module id

1  Asked on September 5, 2021 by user1616338


Pop up AcyMailing subscription form

1  Asked on September 5, 2021 by ygiorgos


Override 3d party extension plugin method

0  Asked on September 5, 2021 by dmitry-zar


Ask a Question

Get help from others!

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