Skip to main content
Share Your Experience: Take the 2024 Developer Survey
6 votes
Accepted

Trigger event for specific plugin only

Generally, an event dispatcher does not support this concept. You're better off directly calling that single function versus going through a dispatcher if you really only want one response from one ...
Michael's user avatar
  • 1,620
6 votes
Accepted

Custom message after plugin installation

Yes, it is absolutely possible. You have to create/use an install script.php file in your installable plugin folder which will include tasks on different points of installation, uninstallation, update,...
Zollie's user avatar
  • 2,936
6 votes
Accepted

How to adjust search keyword sanitization settings as language override?

Look for methods called set<PROPERTY>Callback on the same API documentation you linked. E.g. to override the lower limit use Joomla\CMS\Language\Language::setLowerLimitSearchWordCallback(). I'm ...
Sharky's user avatar
  • 11.4k
5 votes
Accepted

How to call a model method from a system plugin?

This will work with ease in Joomla 3.x //load model JModelLegacy::addIncludePath(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_foo' . DIRECTORY_SEPARATOR . 'models'); /...
Piero Marsilio's user avatar
5 votes
Accepted

Is there an event like "OnAfterCompileHead"?

I have to edit my answer, as I think I didn't get right what you are actually want initially. With all the 3 events you can do changes on the head. If you have other plugins that do the same, then you ...
FFrewin's user avatar
  • 19.7k
5 votes
Accepted

Why is my plugin not hooking into events?

Plugin class name must match the plugin name defined in manifest file. If you have this in the manifest: <filename plugin="installer_log">installer_log.php</filename> Then class name ...
Sharky's user avatar
  • 11.4k
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.4k
4 votes
Accepted

Article custom fields for one category

Right, been playing around and got it working. You're firstly going to need to add the parameter to select a category to your acf.xml file, like so: <config> <fields name="params"> ...
Lodder's user avatar
  • 26.9k
4 votes
Accepted

First Attempt PHP Plugin

So in your XML, you're using name="font-size" for one of the parameters. To call this in the plugin, you simply use the following: $fontsize = $this->params->get('font-size'); You can also add ...
Lodder's user avatar
  • 26.9k
4 votes
Accepted

Simple Joomla plugin doesn't work

The naming convention of the plugin files must be proper. This might be the issue why your plugin class is not rendering. See the example below: Plugin File: nameofplugin.php class ...
Liz.'s user avatar
  • 1,385
4 votes

Available fields in Joomla XML manifest

There is also one other neat trick - when using Radio buttons, you can add Bootstrap class and they will look nicer. Look for class attribute in this code: <field name="some-choices" type="radio" ...
Vladimir Jovanović's user avatar
4 votes

How to call a model method from a system plugin?

To call a model from anywhere inside Joomla you can use this method //Load the Joomla Model framework jimport('joomla.application.component.model'); //Load com_foo's foobar model. Remember the file ...
Amit Ray's user avatar
  • 237
4 votes
Accepted

Get Title from ID

You could try something like the following: public function onYOURFUNCTION($context, &$article, &$params) { $id = JFactory::getApplication()->input->getInt('id'); $load = $...
Lodder's user avatar
  • 26.9k
4 votes

How to use Github as an auto-update deployment server for Joomla 3.x extension

Have a look at the Weblinks repo It does exactly what you want to do. The updateserver points to the manifest hosted on that repo. Download packages are served from the repo as well. Of course you ...
Bakual's user avatar
  • 5,582
4 votes
Accepted

Language files in a plugin

Since Joomla 3.1 it is not necessary to expand the constructor any more, like farahmand's answer. You can easily write / set the $autoloadLanguage like class myPlugin extends JPlugin { /** *...
Tom Kuschel's user avatar
4 votes
Accepted

Override JHtml (HTMLHelper) class methods

Create a system plugin and use JHtml::register() to register your custom methods. defined('_JEXEC') or die; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Plugin\CMSPlugin; class PlgSystemExample ...
Sharky's user avatar
  • 11.4k
4 votes
Accepted

Joomla4 plugin getBody

According to the documentation, JApplicationWeb seems to be alive and well in Joomla4. since 2.5.0 note As of 4.0 this class will be abstract The getters: JApplicationWeb::getBody() Or ...
mickmackusa's user avatar
  • 4,801
4 votes
Accepted

What is the different between JPlugin and \Joomla\CMS\Plugin\CMSPlugin

JPlugin is an alias of Joomla\CMS\Plugin\CMSPlugin. It is the same thing at the moment, but one should start using fully qualified class names because all aliases in Joomla! are deprecated and will be ...
Sharky's user avatar
  • 11.4k
3 votes

Joomla Plugin to fire onUserLogin

I think you need to use the onUserAfterLogin method instead: https://docs.joomla.org/Plugin/Events/User#onUserAfterLogin
David Hayes's user avatar
3 votes
Accepted

Content Plugin 'loads' multiple times on Category Page

Right, so the function executes 15 times and you have 14 articles assigned to a category. If you open the following file: components\com_content\views\article\view.html.php you see the event ...
Lodder's user avatar
  • 26.9k
3 votes

Use of $_SERVER variables in custom plugin

You could create your own library with the functionality you want to re-use in all your extensions and load it each time with JLoader. The $_SERVER is a SUPERGLOBAL variable and can be accessed ...
FFrewin's user avatar
  • 19.7k
3 votes
Accepted

com_ajax and JFactory::getUser()

Assuming you using the correct naming conventions for you Ajax task in the URL and PHP function, you should have something like this: helper.php public static function myFunctionAjax() { } ...
Lodder's user avatar
  • 26.9k
3 votes

Dynamic article filter

I used Minitek Wall. Seems to work really well - I am not technically well versed so I stand to be corrected on that part. Very quick. Only frustrating thing is the lack of pagination in the free ...
tithij's user avatar
  • 31
3 votes

Call content plugin in Joomla! component

Reference here: https://docs.joomla.org/Triggering_content_plugins_in_your_extension in $app->triggerEvent('onContentAfterTitle'); you need to pass some arguments as an array, and you have not ...
Dima's user avatar
  • 41
3 votes

Add <script> tag before </body> on only certain pages?

If you have access to your template, you can use the following code // Detecting Active Variables $option = $app->input->getCmd('option', ''); $view = $app->input->getCmd('view', ''...
Pierre-André Vullioud's user avatar
3 votes
Accepted

Dynamic fields in module parameters

No answers here, but I have managed to work it out for myself. The answer is actually to use both of the solutions I had in mind already -- a custom field type and a subform. My solution works like ...
Simba's user avatar
  • 610
3 votes
Accepted

How to add any text/script before </body>

Plugin code <?php // no direct access defined('JPATH_BASE') or die; class plgSystemMyplugin extends JPlugin { function onAfterRender() { $app = JFactory::getApplication(); ...
jdog's user avatar
  • 953
3 votes
Accepted

How to to create a multi-layered form system

The short answer is: you will need the assistance of a Joomla Programmer as it's highly improbable you'll find a plug-in that suits your requirements. First of all, I think what you are looking for ...
NivF007's user avatar
  • 2,097
3 votes
Accepted

Use plugin code in overrides content template

Content plugins work in all article views whether or not they are overrides. To use them in custom components (whether in overrides or not) you can use the technique explained here: https://docs....
jamesgarrett's user avatar
  • 3,299
3 votes

Language files in a plugin

Load the language files in the plugin's constructor like so: function __construct(&$subject, $config) { $lang = JFactory::getLanguage(); $lang->load('plg_system_myplugin', dirname(...
Farahmand's user avatar
  • 2,295

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