6

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 form, you can simply extend the filelist field type and make it list video files using the formats you want. Here's an example (based on the imagelist field type): ...


5

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 as below global $myPageNavigation; $myPageNavigation = $this->item->pagination; Remove all the snippets that render the pagination which are associated ...


5

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 can re-order them. onAfterDispatch onBeforeRender onBeforeCompileHead To edit the <head> data: The head is stored in the document object and you can ...


4

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 use onBeforeRender, but since you are adding JS to <head>, most logical would be to use onBeforeCompileHead event. This event is triggered before the ...


3

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 results. That's what the onAfterRoute event is for. Create a system plugin. Create a public function onAfterRoute. In there, get $input = JFactory::getApplication()-...


3

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 $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $alias = $active->alias; JFactory::...


3

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 field name value. Put your code in the update method of the installation script so that it will not be execute on fresh installation.


3

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) { // rest of code here } So rather than becoming some long winded array, it will become much more simplified like so: Array ( [test] => Array ( ...


3

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. {source} <?php if (true) { $style = '.item-135 {display: none;}'; $doc->addStyleDeclaration($style); } ?&...


2

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 generated element, and you need to remove one or more unwanted elements, my solution will remove every unwanted element except for the first, then replace the ...


2

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

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 Advanced Module Manager (if you have ever used it). Advanced Template Manager is an extension that changes the way your Template manager works. With Joomla ...


2

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 before the menu items are rendered. The comment in the code is really just a copy and paste issue (hopefully it'll get fixed).


2

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


2

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 the fact that it didn't throw a fatal error suggests to me that either you didn't enable the plugin after installation, or you weren't looking in the control ...


2

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 your code. When System - Page Cache plugin is enabled, on first load page (determined by URL) on is rendered normally with all expected plugin events triggered ...


2

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 JFactory::getApplication()->getBody() The setters: JApplicationWeb::setBody() Or JFactory::getApplication()->setBody() Relevant references and examples: ...


2

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 the different plugin types, but admittedly it can take a while to get your head around them. https://www.youtube.com/watch?v=_agXP5DHm_g&list=...


2

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. The events which are emitted by Joomla are listed in https://docs.joomla.org/Plugin/Events, and these are segregated by plugin type. Unfortunately it's not ...


1

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 manually to default to 0 (the attribute default="0" is accepted in most form types). This will not set the value until the user actually saves the preferences; ...


1

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 to class plgSystemKoy_alias_as_body_class Replace the event onAfterRender with onBeforeCompileHead In the XML file, replace this: <filename plugin="...


1

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 best time to add your content, but it wont work, there's nothing there to add to. Try changing your trigger to onBeforeRender. This is the point where your ...


1

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 resolve the correct language to use. You would also need to be triggering this plugin very early on in processing to ensure the right language files are used. Even ...


1

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


1

/** * Fucntionality which needs to be triggered on After the system has been loaded. * * @since 1.0.0 */ public function onAfterInitialise() { $app = JFactory::getApplication(); // Frontend only, otherwise return. if(!$app->isClient('site')) { return false; } $router = $app->getRouter(); $callback = array($this,...


1

onContentAfterDisplay isn't called at a point when the full getBody() content has been generated. It is rather called at the points where components and modules are generating their individual views. As such, JFactory::getApplication()->getBody() content will not exist at the time you are calling it. Try the following to see which content it is ...


1

That question has been asked so many times and created very long arguments that were never won by anyone. My thought: Take a look at google's website, and see if they use www, and do what they're doing, since they are doing what they think is right, and, as a site administrator, you should only care about their opinion. Note: They use www on google.com, ...


1

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 or guest. False otherwise. And your ? true : false is redundant, since (count($langs) > 1) returns boolean and therefore already equals to true or false. /...


1

If you want to mimic something being set from the URL, you should push it into JInput: $jinput = JFactory::getApplication()->input; $jinput->set('tmpl', 'component'); All code that runs after your plugin will see tmpl=component.


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