Search code examples
joomlajoomla3.0

Why is Joomla 3's JModelBase deprecated? What should be used instead?


Joomla 3 introduced a new MVC classes described here Joomla MVC manual but the classes seem to be deprecated now (for example: JModelBase class docs) and I can't figure out what I should actually use to develop an MVC component for Joomla 3. Which base classes should be used?


Solution

  • If you have a look at some of the core Jooma 3.0 extensions you'll find as of 3.9.14 they are using the following in the banners component:

    Site:

    • item- JModelLegacy
    • list - JModelList

    Admin

    • item- JModelAdmin
    • list - JModelList

    However, as Joomla 4 is almost here and newer versions of joomla 3 support it, I would use the new classes:

    Site:

    • item- class <Component>Model<Section> extends \Joomla\CMS\MVC\Model\ItemModel
    • form - class <Component>Model<Section>Form extends \Joomla\CMS\MVC\Model\FormModel
    • list - class <Component>Model<Sections> extends \Joomla\CMS\MVC\Model\ListModel

    Admin:

    • item- class <Component>Model<Section> extends \Joomla\CMS\MVC\Model\AdminModel
    • list - class <Component>Model<Sections> extends \Joomla\CMS\MVC\Model\ListModel

    Also see Joomla 3 MVC component docs

    And Joomla API Docs