Skip to main content
7 votes
Accepted

Joomla Terminology: view, layout, task and component development

Running ahead a little bit let me provide you with link to JooYii Library. This library makes a leap ahead brings some practices that would be at Joomla! 4 to current Joomla! 3.x branch along with ...
Alexandr's user avatar
  • 1,130
6 votes
Accepted

with insert on duplicate key update - updating multiple rows at once

Building a REPLACE INTO query is just as simple as building an INSERT ... ON DUPLICATE KEY UPDATE. Note that there is a difference between REPLACE INTO AND ON DUPLICATE KEY UPDATE. Code: $columns = ...
mickmackusa's user avatar
  • 4,826
5 votes

Remove /component/ from URL generated from module for a custom component

The /component/name/ part of the url is automatically written by Joomla router when there is no matching menu item found. This is required for the application to route the command to the proper ...
Nagarjun's user avatar
  • 3,001
5 votes
Accepted

Using external library with a component

If you're only ever using a library within a single component then there's no reason not to include it in a folder in the component - this is the way that distributed components will generally handle ...
jamesgarrett's user avatar
  • 3,319
5 votes
Accepted

How to generate a dynamic note field for a custom component?

Use Form::setFieldAttribute(). Typically, this is done in the model's getForm() method. However, if it's cosmetic only, it can be done in the view too. In /administrator/com_image/models/forms/image....
Sharky's user avatar
  • 11.5k
5 votes
Accepted

How to use HTMLHelper to add to the document head

1) JHtml is an alias for Joomla\CMS\HTML\HTMLHelper class. You'll have to start using the real class sooner or later because the alias will not exist in Joomla! 5.0. To use the real class you have to ...
Sharky's user avatar
  • 11.5k
5 votes

Content plugin doesn't add text to articles

Your plugin appears to be written for a very old version of Joomla! The event in current versions is onContentBeforeSave. You are also missing $context argument. It's a good idea to check for context ...
Sharky's user avatar
  • 11.5k
5 votes

'getErrorMsg' is deprecated in Joomla 4 and what would be the equivalent

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 ...
Zollie's user avatar
  • 2,946
5 votes

New files in Joomla 4 components

An excellent resource for Joomla 4 extension development is "Joomla 4.x Tutorial - Extension Development - The Way to Joomla 4 Extensions" written by Astrid Günther: https://blog.astrid-...
pe7er's user avatar
  • 2,068
5 votes
Accepted

New files in Joomla 4 components

services/provider.php should return a service provider which is used to register services with the service container and set up initial dependencies. This is the only file with a hardcoded filename ...
Sharky's user avatar
  • 11.5k
4 votes

Calling Joomla!'s Default 404 Page

In your Joomla installation directory reach templates/themeXXX/error.php file. Edit the error.php file as shown below, locate this line of code: If you don't want to change address bar url then you ...
Sudhir Sapkal's user avatar
4 votes
Accepted

Joomla 3.9.1 publish/unpublish no longer working (custom components)

Inside your table's constructor use setColumnAlias() to define the actual column name: public function __construct($db) { parent::__construct('#__example', 'id', $db); $this->...
Sharky's user avatar
  • 11.5k
4 votes
Accepted

Select articles to display in custom component

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 ...
Sharky's user avatar
  • 11.5k
4 votes

'JEventDispatcher' is deprecated in Joomla 4 and what is the replacement

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in ...
Sharky's user avatar
  • 11.5k
4 votes

How to create a (better) development environment for Joomla 4

I've not used Docker so I can't help with that, but I have xdebug set up on my local environment in combination with PHPStorm and that is a big help in enabling me to figure out why something's not ...
Grant Hood's user avatar
3 votes
Accepted

Purpose of metadata.xml

So the purpose of metadata.xml is storing the data that need to be shared across layouts: each layout.xml inside of your view tmpl directory extends metadata.xml. So if you need to put some request ...
Alexandr's user avatar
  • 1,130
3 votes

Loading custom classes in a component automatically

If the utility classes are only used in your component then include them in a folder within your administrator component. Whether you register the classes with JLoader or just require_once them just ...
jamesgarrett's user avatar
  • 3,319
3 votes
Accepted

Bulk insert records in database from excel

I solved the issue. Problem was that when insert query was called in a loop 2000 times, deadlock occurred and returned a blank page. The solution to this is to construct one single insert query and ...
Liz.'s user avatar
  • 1,385
3 votes
Accepted

Subform multiple data not saving

In your table's bind function, add this: if ( ( !empty( $array[ 'list_links_url' ] ) && ( is_array( $array[ 'list_links_url' ] ) ) ) ) { $this->_jsonEncode[] = "list_links_url";...
Stuart Steedman's user avatar
3 votes
Accepted

Redirect after login by component

You can create a plugin that triggers on onUserAfterLogin and redirects the user to where you want. or you can add a &return= query variable to your links to the login page as described here
Drew G's user avatar
  • 890
3 votes

Set Prefered Template with parent:display()?

You can force the template style like this: $templateStyleId = 3; // set here the template style id $app = JFactory::getApplication(); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/...
Dennis Heiden's user avatar
3 votes

Create SEF URLs from a Custom Component that does not search on database

One thing is, that you're trying to create a router in the old way, it changed over time. Now router is a class. Second thing is, one of your component views have to be set as a front-page for a ...
Artur Stępień's user avatar
3 votes

Proper Way to Migrate Custom Website to Joomla

You can certainly add CSS or JavaScript by creating a plugin or module but the quickest and easiest way to do this is probably using a third party extension such as the EasyScript plugin or the Flexi ...
Neil Robertson's user avatar
3 votes
Accepted

onUserAfterLogin popup - Joomla 3.6.4 Plugin

The return value of onUserAfterLogin() should be a boolean -- ie true or false. The idea is that you can use this event handler to do additional validation on the login, so if you return false, it ...
Simba's user avatar
  • 610
3 votes

Problems with Custom form field select list

You can check the field from where it is coming, <? php echo $this->form->renderField('partno'); ?> This line rendering your field 'partno', by looking into generated html it seems it is ...
Sudhir Sapkal's user avatar
3 votes
Accepted

Problems with Custom form field select list

raVan96 is bang on, you should have either a sql field or a list field. But, what you have was an sql field that you have replaced with a custom list field. There are two main issues. The form xml ...
jamesgarrett's user avatar
  • 3,319
3 votes
Accepted

Manually render filter form fields in layout

Include group name as the second parameter in renderField(), e.g.: echo $this->filterForm->renderField('published', 'filter'); echo $this->filterForm->renderField('limit', 'list'); Or if ...
Sharky's user avatar
  • 11.5k
3 votes
Accepted

How does JFactory::getApplication->input get the input id

If I understand it right. You wan't to get the ID of the current active menu. Theres a great example on this forum: https://forum.joomla.org/viewtopic.php?t=642224 Here's the code part: // get ...
Jonas Borneland's user avatar
3 votes
Accepted

Getting user id of logged in user in component

You are doing it right but your user object is not empty. [id] => 0 because the current user is not logged in. Try to login and do something like: use Joomla\CMS\Factory; $user = Factory::getUser()...
pe7er's user avatar
  • 2,068
3 votes
Accepted

Is there a way to remove component media files on update?

Create a installer script for your component (com_your_component_name/script.php) and add the following code: <?php defined('_JEXEC') or die; class com_your_component_nameInstallerScript { ...
webchun's user avatar
  • 2,418

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