Question

I'm developing a component for Joomla 3, but I don't understand how to use the datamodel in joomla 3. Am I supposed to use the Legacy-classes? Will these not be deprecated after a while?

I see most of the joomla components are using the class JModelList, which extends JModelLegacy. To load such a class I can use

JModelLegacy::getInstance('classname');

but is there a way to do this without using legacy-classes? I would think that the word legacy implies that the code hase been replace for something newer/better/hotter? Please enlighten me if anyone knows better ...

PS: I also asked this question on the Joomla - forum, but got no replies (http://forum.joomla.org/viewtopic.php?f=706&t=837707)

regards Jonas

Was it helpful?

Solution

I tend to use JModelList and JModelForm because this way PHP error logging will notify during code execution if your class has failed to meet some of its "contractual" class obligations from any of the parent/super classes.

The answer depends on yourself, and there is really no "wrong" answer here. Pick the method which makes the most sense to you and go with it.

** EDIT **

You can always load and instantiate a model class like so, using User's registration model as example.

JLoader::register('UsersModelRegistration', JPATH_ROOT . '/components/com_users/models/registration.php');
$model = new UsersModelRegistration();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top