New answers tagged

4

JControllerLegacy::getInstance() caches the first controller instance so you're actually getting an instance of your component's controller rather than Content controller. You can skip the controller and get the model directly instead: JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel'); $model = JModelLegacy::...


0

I managed to find this page in JDocs, while not looking for it, that looks like the closest thing to any sort of formal documentation although it is minimal. https://docs.joomla.org/J4.x:Namespace_Conventions_In_Joomla It is a start but it could do with a lot of more elaboration to put things in context as provided by @Sharky in his answer.


2

Components in J4 use a service-based approach which, in theory, should allow any naming convention. Although for that you'd have to write your own factories. But if you want to follow same conventions as Joomla core components, start by declaring a namespace in the component's manifest file. The namespace should be in this form: [Vendor]\Component\[Component ...


1

Did you have a look at the Joomla code itself on Github too? https://github.com/joomla/joomla-cms/tree/4.0-dev When I take a look at the php files in the tmpl directories of components and modules I see the following setup for classNames. modules => mod-modulenmame components => com-componentname For instance com_contact. The className for a single ...


Top 50 recent answers are included