Questions tagged [best-practices]

This tag should only be used when a key objective in the question relates to any combination of: efficient processes, sustainable architecture, Joomla! Coding Standards, general web security, direct/purposeful actions, and other such foci where optimisation is valuable. This tag is most appropriate when a basic solution is already realised, but refinement is sought.

Filter by
Sorted by
Tagged with
1 vote
1 answer
64 views

Joomla 4: no need for Route::_($url)?

I am using this on a custom component: $url = index.php?option=com_content&view=article&catid=427&id=15106 Both echo $url; echo Route::_($url); will output a friendly url. I'm guessing ...
Alexandre Paulo's user avatar
0 votes
0 answers
35 views

Map records from the model to classes

In various tutorial, I see models, which provide data to the controller by means of arrays. While this might be OK, I wonder if mapping these records to a model item classes wouldn't be better: If ...
SteAp's user avatar
  • 163
2 votes
1 answer
97 views

Display instructions or other text in Plugin

I would like to display some basic text, instructions and maybe a change log in HTML would be nice, under the first tab of my Plugin, what methods or techniques are available? In my sample screen shot ...
Irata's user avatar
  • 3,597
1 vote
2 answers
1k views

Best practices for Joomla - Get another model in a view from another controller

I need to get data from another model than the view specific controller/model into the view. But I'm not sure if the way I'm doing it now is correct. I do that via the following way in the view.html....
Kuubs's user avatar
  • 345
0 votes
1 answer
48 views

How do you organise your code in a Joomla extension?

I am looking for examples of how people organise their code in a Joomla extensions, particularly components, that is beyond the basics shown in tutorials teaching you MVC and Joomla. A look through ...
Irata's user avatar
  • 3,597
0 votes
2 answers
48 views

What directory should contain GPL scripts from external source? Best practice?

I am making a custom gallery module using Light Gallery. In most cases, I would just place all my JS files inside /assets/js directory. But I wonder if this is good practice when using an external ...
TVBZ's user avatar
  • 213
0 votes
1 answer
185 views

Create a User Area

I'm wondering how i can create a User Area for users to login and gain access to a user panel (where user can update their info and specfic/custom actions). Because the Joomla user login ...
Thiago Guimarães's user avatar
1 vote
1 answer
347 views

Which one to use? grid.sort vs searchtools.sort

I have been looking at why column sort orders wouldn't change in the front list view of my component and found by changing <?php echo HtmlHelper::_('searchtools.sort', 'JGRID_HEADING_ID',...
Irata's user avatar
  • 3,597
4 votes
1 answer
148 views

How is onContentAfterSave working in the Front End?

I have created a plugin that works using onContentAfterSave to fire off some other processing once a record is saved. This works as expected in the Back End but nothing gets triggered when I save a ...
Irata's user avatar
  • 3,597
3 votes
1 answer
210 views

Issues to be aware of when calling `concatenate()`, `regexp()`, `rand()`, and `castAsChar()` in sql queries

I'm taking it upon myself to become aware of some of the lesser known/used query methods because I like toying with MySQL and I want to implement Joomla calls when possible/sensible -- because they ...
mickmackusa's user avatar
  • 4,781
4 votes
2 answers
866 views

Can I safely disable the core components I don't use

I don't really use: Contacts Banners Search Newsfeeds So my question is: Are they safe to disable? Are they safe to uninstall? Ideally, I'd like to make my installation as lightweight as ...
Eoin's user avatar
  • 1,889
3 votes
1 answer
387 views

Where to call for CSS/JS in custom component for frontend views

I've created a custom component with a dashboard that needs styling with CSS. I've created the CSS file and I'm looking at calling for it in the frontend view. Working with J! 3.6.5 and a MVC ...
Badger's user avatar
  • 113
0 votes
2 answers
5k views

What is the best way of using PHP code in Joomla's articles or modules?

Let's say I need to create a simple page and for my links I want to use JRoute::_() in order to make them SEF or display ID of the current user. What would be the best way to achieve this? Joomla by ...
Adam M.'s user avatar
  • 447
6 votes
1 answer
1k views

How to add a composer package without modifying the core composer.json file

I am trying to add a Composer Package and make it globally available but I do not want to modify core composer.json for obvious reasons. Is the only way to do this having a composer.json either on ...
sifu's user avatar
  • 1,105
2 votes
1 answer
801 views

Can we create different configuration.php file for multiple environment?

We have a project setup which has three different git branches (development, staging and production). We are trying to find the best way to setup (if possible) the configuration.php for each branch. ...
sifu's user avatar
  • 1,105
1 vote
1 answer
955 views

Site gets hacked and everytime a new user is created with Admin rights

We are facing a weird problem. We have a site set-up in Joomla. The site is getting hacked on a regular basis and specifically during the weekends. The strange thing is, we see that a new user is ...
Amar's user avatar
  • 11
0 votes
1 answer
48 views

What steps shoud I include in a health check on an existing Joomla website I am being asked to look after?

I am sometimes asked to adopt orphaned Joomla websites when the original service provider is no longer able or available to do so. What steps should I include in a health check before agreeing to ...
Neil Robertson's user avatar
4 votes
2 answers
3k views

What is the best way to require_once?

METHOD 1 Hard coding the directory separator require_once JPATH_COMPONENT.'/models/fields/courselist.php'; METHOD 2 Soft code the directory separator if(!defined('DS')){ define('DS',...
Malaiselvan's user avatar
  • 2,721
1 vote
2 answers
916 views

Proper way to call/use plugin parameters

I know this could be interpreted as a minor or a newbie question but I would like to improve my code. So, in a best coding practice perspective how to call/use plugin parameters? My two code examples ...
n.h.'s user avatar
  • 871
8 votes
2 answers
384 views

Where to place code in Joomla modules

When developing a Joomla extension, are there any best practices, guidelines or recommendations regarding where to place the different parts of my code (PHP and HTML)? I'm mostly thinking about the ...
johanpw's user avatar
  • 13.3k