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::...


3

I try to give just a short answer on this. We cannot say that there is an “equivalent” of your code snippet in Joomla 4 since Joomla has been handling errors with using core PHP Exceptions. And your code sample would get error in newer Joomla 3 also. The old JError class were deprecated quite long time ago (at Joomla 3.1). The code editors shows this ...


3

Use the fully qualified class name which is Joomla\CMS\Helper\ModuleHelper. To get this information in your IDE, you can run build/stubGenerator.php script via PHP command line. This will generate a stub file of deprecated class aliases and the new classes to use. This is how it looks in VS code:


2

I consider this a very valuable question that does not have good write-ups/tutorials yet in Joomla documents (we should create one). I am trying to give here some workable info on this. Loading Form Fields using Joomla implemented show-on conditions is not for loading dynamically changing checkboxes, list or combo field's values and fields. For loading Form ...


2

My approach would be to update your code to move away from JModelLegacy and by placing the addIncludePath in the subcontroller using the following lines. mycomponent/controller/messages.php Use Joomla\CMS\MVC\Model\BaseDatabaseModel; . . . BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_mycomponent/models'); $this->msgsModel = ...


2

save() calls store(). Store() works like this: If a primary key value is set the row with that primary key value will be updated with the instance property values. If no primary key value is set a new row will be inserted into the database with the properties from the Table instance. Please check, if the primary key of the database table is set in your $data ...


2

As demonstrate by my answer at with insert on duplicate key update - updating multiple rows at once, I recommend using Joomla's secure query building methods, then performing any necessary surgery when calling setQuery(). I reckon this is the best you can do. Just be sure that your surgery CANNOT accidentally "over-replace" or otherwise ...


2

Been a while since I used repeatable form fields (deprecated and subform fields should be used instead), but if I rightly remember, the repeatable form fields response format was a little different. It grouped each column in an array rather than each row. So what you'll need to do is define a function to group the values by key: function groupByKey($array) {...


2

It's how Repeatable field stores its data. Pick a field to iterate over and use its key to access value of another field: foreach ($carousel_images['carouselimage'] as $key => $image) { // do something clever for each of the images '<img src="' . $image .'"><p>' . $carousel_images['carouselcaption'][$key] . '</p>'; } ...


1

Components aren't really meant to be rendered more than once per request. Your best bet would be to make separate requests. Wrapper component and module can be used to display the page using an iframe. Or you can retrieve the page in PHP using HTTP library. There is Components Anywhere plugin which uses this method https://extensions.joomla.org/extension/...


1

One way is to explicitly specify the class with an inline doc block: /** @var \Path\To\BookModel $model */ $model = $this->getModel('book');


1

This was actually a bug in the Joomla Browser and has been fixed now. See https://github.com/joomla-projects/joomla-browser/pull/216 The current version should be able to create new menuitems.


1

After more hours trawling through the Joomla libraries to understand how the Query process is working, I can say that converting the $query object to a SQL command string and replacing the current statement with the required statement is the easiest way that I can see to make this work. This is what is covered in the linked answer by @mickmackusa. From Mick'...


1

I think that you could do this using a modal window, but it will be rather involved. The Joomla MVC tutorial step adding a modal and associated video will provide some background help, but it will need to be adapted a fair bit. Referring to the code in that tutorial step, these are the main things I think you'd need to change. Your button which results in ...


1

I'm assuming that since you're asking about SEF URLs for your component that you've already built your own custom router (as SEF URLs for a custom component are dependent upon that). If not then you can follow the example described in https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_an_alias and following tutorial steps. If you've done that ...


1

First of all you may well be able to use the Joomla SQL Form Field for your Job Title field, instead of having to write a custom field. To make the Technologies dropdown dependent upon the Job Title field you may be able to use the showon attribute as described in Enabling showon to work in list options. In your Technologies custom field you'd have to select ...


1

I have been fighting the same problem for two full days now, going over lesson 10 of Robbie Jacksons excellent video explanations in this series https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Developing_a_Basic_Component again and again. In lesson 10 he tries out his own alternative approach and he comes up with this redirect in his subcontroller ...


1

It seems you mispelled the filename the correct name is access.xml without the capital A. Another thing you might want to look at is if you added the rules field in config.xml file. Lastly, if you have declared both of these files in your component's manifest in the administrator files part. Like so: Note: I just put the revelant part of what your component ...


Only top voted, non community-wiki answers of a minimum length are eligible