The Stack Overflow podcast is back! Listen to an interview with our new CEO.
7

helper.php: This file is where all your functions belonging to a class should go. It's basically the module version of a model for a component, so tasks such as performing database queries etc. The benefits of this file is that it keeps all the core functionality in 1 location. If a module already contains this file, 1 simple rule, do not remove it. ...


6

Regarding how Joomla loads configuration.php in index.php, at line 29 if (file_exists(__DIR__ . '/defines.php')) { include_once __DIR__ . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', __DIR__); require_once JPATH_BASE . '/includes/defines.php'; } You can put a custom defines.php in the Joomla root directory, then ...


6

Technically in PHP you can also do this: if ($my_parameter = $this->params->get('my_parameter', 'default_value')) { ... $xpto = $my_parameter; ... } This assigns the variable and then checks that the variable is 'true', which in PHP means that it isn't null, false, '', or 0. So depending on your default value, the if statement could be ...


6

Joomla got rid of the DS constant with Joomla 3. It's no longer needed in most cases since PHP works fine with a forward slash even on Windows. So don't use it.


5

Basically, mod_mymodule.php is a bootstrap page of your module. Here you will include helper file and call necessary function which resides in helper.php. you can put HTML code in tmpl/default.php page and php code in helper and mod_mymodule.php page. For more detail please see this. Thanks.


4

I don't know if there's any difference in speed, but I find the first method easier to read. The reason to use DIRECTORY_SEPARATOR is to stay platform independent. Your second example: 'models'.DS.'fields'.DS.'courselist.php' would render like this on on Windows: models\fields\courselist.php and like this on most other systems: models/fields/courselist....


4

I suspect that modifying Joomla's root composer.json file will come with Joomla 4. In the meantime, I think the best way to use composer packages is to include a composer.phar in a custom system plugin and then call the autoloader on the onAfterRoute event. Then it's globally available or if you want to only load the autoloader for 1 component for example ...


4

I always disable any of the core components that I won't use and this is a safe approach. I wouldn't recommend to uninstall at this phase until Joomla removes them from the core as it happened with WebLinks. For a component being part of the core means that they will be back with the next Joomla update - plus if they are not present, there is some ...


3

com_content frontend form model extends the backend model which in turn extends Joomla\CMS\MVC\Model\AdminModel. The backend model has a custom save() method where the event is triggered. Meanwhile, your frontend form model extends Joomla\CMS\MVC\Model\FormModel which has no such event and no save() method. The simplest solution would be to trigger the ...


3

All of my demonstrations will assume this line is already declared: $db = JFactory::getDBO(); I will also provide a "guinea pig" table as a demo reference and playground for researchers when sample data is necessary for context. (db-fiddle.com demo) CREATE TABLE IF NOT EXISTS `#__calendar` ( `id` int(11) NOT NULL AUTO_INCREMENT, `month` varchar(100) ...


3

There are many resources you can find regarding a Joomla hacked site, either by googling it, or simply searching in this site. Here are some links: What to do if my Joomla website got hacked? How to secure a new Joomla installation? Joomla Security CheckList Make sure you read them carefully and take all actions that apply to secure your site. Now, ...


2

This is a risk when you don't know how the previous programmer developed the website. First of all check all extensions installed and if they are updated. If not, check if the extension has an available update and it's still supported... alternatively look for a similar extension to switch with. Check also the template version (responsive?) and if it ...


2

Locked ones are required for Joomla to work, so you shouldn't unpublish or uninstall them. The others may be required for some third party extensions to work (as they are part of core Joomla, the assumption that they exist may be made by some developers.) I have uninstalled some of these in the past without problem, but now tend to use ACL instead - day-to-...


2

I'd suggest placing it in your view file: components/com_mycomponent/views/VIEW_NAME/tmpl/default.php This means that is anyone wishes to override your component views, they can, for example, remove your CSS file being referenced and use their own.


1

For that, I use NoNumbers Sourcerer: https://www.regularlabs.com/extensions/sourcerer


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