11

If you have a look at the Joomla addScript function, it shows the following: public function addScript($url, $type = "text/javascript", $defer = false, $async = false) { $this->_scripts[$url]['mime'] = $type; $this->_scripts[$url]['defer'] = $defer; $this->_scripts[$url]['async'] = $async; return $this; } $async is a boolean ...


7

The JDocument's addScript method has no options for ordering (eg by priority or something like WP). There are numerous ways to solve your problem. First, to understand why what you're doing is causing the problem you need to know the Joomla lifecycle. Bootstrap Framework & Application Route Component Modules Template Render and Respond So when you ...


7

To load CSS and Javascript files, you want to use JUri::base() instead of JPATH_COMPONENT_ADMINISTRATOR. Also have a look at a more advanced loading mechanism, JHtml. Adding JavaScript and CSS to the page


4

You should be able to do JFactory::getDocument(); in most places within Joomla (component, module, plugin, etc) to get the document object. And then you are correct, it is a call to setHtml5 like this: $document = JFactory::getDocument(); $document->setHtml5(true); This is the function declaration in Joomla's core for reference: https://github.com/...


4

module_name.php file can't be overridden. Check to see if the module has options to disable the loading of its scripts - Many modules come with such settings. If it hasn't, then you could propose this to the developers of the modules to include it in the next release. You can always clone the module and make one of yours that will behave the way you want. ...


3

It is generally a component that overrides the template files as you discovered. I personally build my sites of Zurb Foundation 5 - so I'm always removing bootstrap. So I would look at: Overriding the component and the code it generates - however this is usually a core file that will be overwritten when you upgrade the component Custom plugin - see ...


2

A simple code review: You don't need the condition block because getScriptOptions() always returns an array. getScriptOptions() documentation If you want to declare the variable $configs... $configs = $document->getScriptOptions('mod_mymodule'); $configs[$module->id] = $params; $document->addScriptOptions("mod_mymodule", $configs); If you ...


1

Okay.. Found the solution. Here we go: $configs = $document->getScriptOptions('mod_mymodule'); if ($configs) : $configs[$module->id] = $params; else : $configs = array($module->id => $params); endif ; $document->addScriptOptions("mod_mymodule", $configs); The logic wasn't that hard. I'm still pretty new at php and Joomla! ...


1

This most likely means that you are adding non-existing assets. Their links generate a 404 page which is why you're getting the text/html MIME type instead of respective types for CSS/JS files.


1

This kind of error comes from what is known as CSP (Content Security Policy) configured on your web server. If you don't know what it is. Please contact your hosting provider. For any information you can read this article on MDN (Mozilla Developer Network) Take care. Hope it helps.


1

I also had to show component output in an iframe on another domain. I ended up creating a very simple template showing only the component output. I added the base target line in the template's header. Then instead of tmpl=component I used tmpl=simpletemplatename.


1

You can't use standard Joomla {loadposition} content plugin for this purpose because content preparation occurs much before head data preparations. You will need to write your own Joomla System plugin for the replacement like NoNumber's Module Anywhere plugin which replaces the mos code with the module after head data preparation. To learn more refer to ...


1

No there isn't. addScript(string $url, string $type = "text/javascript", boolean $defer = false, boolean $async = false) You can use $defer and $async parameters of the addScript method to load JavaScript after the content. Example: $doc->addScript($path.'/js/script.js', 'text/javascript', true, false); Use $defer = true if you want to load scripts ...


1

You have to (pre)-load the frameworks and your own JavaScript files in the right order in your extensions. The template is too late and nothing is loaded by default. Example for a module's tmpl file: JHtml::_('bootstrap.framework'); // alternative only JQuery JHtml::_('jquery.framework'); JHtml::script('mod_yourmodule/yourmodule.js', false, true, false, ...


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