6 votes

How to allow media manager open video files

The best way to allow video selection in an extension field is to use a custom field. For an introduction to custom fields, take a look at this article from Joomla! Documentation. In its simplest ...
  • 13.3k
5 votes
Accepted

Can't add Javascript in plugin

As the name of event onAfterRender says: This event is triggered after the framework has rendered the application. So application has been already rendered, you can't edit it anymore. You could ...
  • 3,208
5 votes
Accepted

PageNavigation Plugin

Edited Assuming you have created a template override of the article view, then you have to modify a few things at templates\mytemplate\html\com_content\article\default.php Declare a global variable ...
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 ...
  • 19.5k
4 votes
Accepted

Easiest way to add a class to the body

Remember that if you want to use vanilla JS, you need to use the equivalent of jQuery's document.ready() method. So you want to use document.addEventListener('DOMContentLoaded'), like so: <?php ...
  • 26.5k
4 votes

using the sourcerer plugin the code written in php disappears

From https://www.regularlabs.com/extensions/sourcerer/tutorial: Sourcerer already creates the $document (or $doc) object for you when it is needed. So you do not have to initialize this yourself. ...
  • 4,493
3 votes
Accepted

Is it possible to change the requested component and view with a system plugin?

The currently accepted solution is overcomplicated and bound to cause problems. Don't mess with fundamentals, like the URL and PHP superglobals when all you want to do is modify Joomla's routing ...
  • 521
3 votes

Easiest way to add a class to the body

The jQuery part must be called in the document.ready() event. Try this: $javascript=' jQuery(document).ready(function(){ jQuery("body").addClass("' . $alias . '"); }); '...
3 votes
Accepted

Change existing xml field name values

Yes, you are right. You can use installation script to update the field name and value on the plugin upgrade. Write sql to update the plugin data, stored in the database, as per the current plugin ...
  • 1,791
3 votes

Export/Import from security perspective

First thing I would do is use JInput instead of using $_FILES, like so: $jinput = JFactory::getApplication()->input; $files = $input->files->get('jform1'); function import($files) { //...
  • 26.5k
2 votes

How to replace the content of Div for plugin

There are some grey details in your question, so I'll post a solution what I think will do as you desire using DOMDocument and a direct XPath query. Because your question appears to only have one ...
  • 4,493
2 votes

How to replace the content of Div for plugin

Possible other solutions: Use https://www.nonumber.nl/en/extensions/rereplacer Find the php code that writes this wrong div and replace it with your own code Use jQuery to replace the divs
2 votes
Accepted

Can all events be usable from any plugin?

All the Joomla events are categorized for different purpose. And each event trigger will be available only for those plugins which actually serve that purpose. If there is an authentication type ...
  • 1,791
2 votes

Assign different single article template per category

Yes, it's possible. You can do it with a system plugin. However there is already a such solution available by Regular Labs. It's called Advanced Template Manager, and it works similarly to the ...
  • 19.5k
2 votes

What is the difference between onAfterGetMenuTypeOptions and onBeforeRenderMenuItems plugin triggers

The main difference between any plugin triggers is the timing at which they run. onAfterGetMenuTypeOptions is triggered after the menu types are returned, and onBeforeRenderMenuItems is triggered just ...
  • 3,186
2 votes

How can I display a message based upon the value of a config item

This JFactory::getapp(); should be JFactory::getApplication(); or because the app property has already been made protected above you can just use it like $this->app->get('robots'); but ...
  • 3,144
2 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 ...
  • 4,493
2 votes
Accepted

onAfterRender plugin only triggers on backend

The code you currently have works. You just need to clear page cache and view the page again. You'll see fonts.googleapis.com links are removed. This may or may not be fine depending on the rest of ...
  • 8,741
2 votes

Creating a plugin to insert a Chrome Trial Token

If I were you I would try this instead of onBeforeRender: onBeforeCompileHead That way you are adding the meta to the document prior to it being rendered. Here is an excellent video explaining all ...
  • 1,839
2 votes

Creating a plugin to insert a Chrome Trial Token

Plugins can be fickle things to get right, so here's a short guide to getting your plugin working successfully. Identify the Plugin Type and Event Firstly work out which event you need to subscribe to....
2 votes
Accepted

addScriptDeclaration is not working

$document->addScriptDeclaration() method is working, no problem with that. window.event is deprecated: https://developer.mozilla.org/en-US/docs/Web/API/Window/event instead of that you should use ...
  • 2,436
2 votes

addScriptDeclaration is not working

You are using onAfterRender event which is not suitable for modifying the document object because this event is triggered after the page has already been rendered. Use onAfterDispatch, onBeforeRender ...
  • 8,741
1 vote
Accepted

How to add the alias to the body in a plugin

I'm not sure why you're using onBeforeCompileHead. As per the docs, https://docs.joomla.org/Plugin/Events/System, this is triggered before the head is even created. Maybe you thought this would be the ...
  • 677
1 vote

How to change the site language by country IP

If the client forces it, I would go with the @mickmackusa approach and check if the language has been set via a value in the session and only if it hasn't then execute your code to get the IP and ...
  • 2,350
1 vote
Accepted

Develop a System Plugin with Sample Data for Options

I am not sure there is not a simpler way. But this way you'll get what you want. a) Create a custom field to implement your logic. You can extend from any basic custom field types. b) Simply set it ...
1 vote
Accepted

onAfterRender plugin issue

Ok I've debugged this now. I'll write this down in simple steps: Change the PHP file name to koy_alias_as_body_class.php Change the XML file name to koy_alias_as_body_class.xml Change the class name ...
  • 26.5k
1 vote
Accepted

Flag based on Language and Two Factor Authentication

There is better way for getting $flagFactor. $flagFactor = JPluginHelper::isEnabled('twofactorauth'); This returns true if any of twofactorauth type plugins is enabled and accessible by current user ...
  • 3,208
1 vote

How to override language filter plugin?

Template overrides are for layout files. You can override a plugin's layout/template files, assuming the plugin is designed this way. But this cannot be used to change behavior of system plugins. ...
  • 19.5k
1 vote

Installing Language Filter and Language Code system plugins

Ok my bad, they were installed. I failed to find them because their names were translated into French in the administration panel...
  • 121

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