Skip to main content
8 votes
Accepted

how to display message in joomla using javascript

It expects the messages to be passed in an array, even if there is only a single message, ie Joomla.renderMessages({"success":["this is test message"]}); The formatting example given in the source ...
RichardB's user avatar
  • 3,092
8 votes
Accepted

Control order of loaded scripts

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 ...
jamesgarrett's user avatar
  • 3,319
7 votes
Accepted

Add script just after <head>

First, according to the docs AdSense code doesn't go after the <head>, it goes between the <body> tags. JavaScript should almost always be placed at the end of the body, just before </...
Bathmat's user avatar
  • 502
5 votes
Accepted

How to use HTMLHelper to add to the document head

1) JHtml is an alias for Joomla\CMS\HTML\HTMLHelper class. You'll have to start using the real class sooner or later because the alias will not exist in Joomla! 5.0. To use the real class you have to ...
Sharky's user avatar
  • 11.5k
5 votes
Accepted

Best Practice: Loading component Styles & Scripts in J4

Both have pros and cons. Web Asset Manager is great if your loading an asset that depends on another one. For example: some jQuery plugin that depends on jQuery Your json file can set jQuery as a ...
Lodder's user avatar
  • 26.9k
5 votes
Accepted

Can I delay loading a css file until a user is logged in?

Very interesting and good question in my opinion. For this task I would use the 'joomla_user_state' cookie which is available from your template index.php file. (otherwise you can do this form a ...
Zollie's user avatar
  • 2,946
4 votes
Accepted

Can't insert intro/full article image

You have either some files corrupted on update, or some outdated server software. Overwrite your web-site with Joomla 3.6.0 full package to be sure it's no a file corruption (extract the Joomla full ...
AHeavyObject's user avatar
4 votes

How can I insert js scripts before </body>

I think there are at least 4 options. In gantry5 templates go extension>templates, select your template, and on the page settings tab there is a textbox labeled "Before </body>". This will be ...
jamesgarrett's user avatar
  • 3,319
4 votes
Accepted

How to overwrite a module's .php to control what scripts it adds to the head of the doc?

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 ...
FFrewin's user avatar
  • 19.8k
4 votes
Accepted

How can I add a local custom javascript file into the bottom of the template's index.php file?

Unfortunately Casseopeia (default Joomla 4 frontend template) uses the following: <jdoc:include type="scripts" /> inside the <head> tags at the top of the DOM, so any script ...
Lodder's user avatar
  • 26.9k
4 votes
Accepted

How to add a piece of JavaScript code to the header?

Find your templates index.php file: [httpdocs]/templates/[YOURTEMPLATE]/index.php In the index.php file, find the <head> tag and add your snippet there using <script> tags. Example <...
Guitarman's user avatar
  • 192
4 votes

How to Fix PHP Deprecated : Factory::getDocument() is deprecated

Use Joomla\CMS\Application\WebApplication::getDocument(). In your code you're already doing this with $app->getDocument().
Sharky's user avatar
  • 11.5k
4 votes

JRequest Method in Joomla 4

Use Joomla\Input\Input class. Instance relevant to the current request can be accessed through the application: use Joomla\CMS\Factory; $controller->execute(Factory::getApplication()->getInput()...
Sharky's user avatar
  • 11.5k
3 votes
Accepted

What's the correct way of adding code after the start of the body tag?

Complementing the answer from @veritas399, you could also use a third party extension such as EasyScript or similar to insert the code into your web page without worrying about future template or ...
Neil Robertson's user avatar
3 votes

What's the correct way of adding code after the start of the body tag?

If you don't want to edit the template's index.php file, then I'd suggest that you use a plugin and utilise JApplication to get and set the body. You can then use the following in your plugin: ...
Lodder's user avatar
  • 26.9k
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

how to display message in joomla using javascript

The above answer is great, below is some code to add a title to the message. As a side note, you can also load other strings & use those to create a custom alert. The title of the string is added ...
cybersholt's user avatar
3 votes

How do I add "id" to script declaration

JDocument has a method for inserting arbitrary characters into the head tag. People usually use it for meta tags etc. It's down the bottom of this page: https://docs.joomla.org/J3.x:...
jamesgarrett's user avatar
  • 3,319
3 votes
Accepted

Placing inline javascript into the head tags of one page only

I love Regular Labs Sourcerer and use it on quite a few websites but if you only want to add code into the header area of a specific page, the easiest way to do this is to use the HeadTag plugin (free)...
Neil Robertson's user avatar
3 votes

"0 Class 'JToolbarHelper' not found" error while trying to login to the backend

I was able to solve the issue thanks to the help from github. Add following code to the /sitefolder/administrator/includes/helper.php: if(!class_exists('JToolbarHelper')) { require_once ...
vondravl's user avatar
3 votes
Accepted

How to include scripts in <head>

Default Joomla behaviour is to add scripts to the head element. Try looking where <jdoc:include type="head" /> appears in your template (under template/YOURTEMPLATE/index.php) - it may have ...
RichardB's user avatar
  • 3,092
3 votes
Accepted

How to check JSESSION in javascript

One way I can imagine to check the session is before you ignite the above ajax call, you make a previous ajax call to another function in com_contract/controller(task = your new session checking ...
Zollie's user avatar
  • 2,946
3 votes
Accepted

Client side validation - custom event handler not called when user enters the field and leaves it being empty

I deleted my earlier answer, since it was on some points true but not exactly answered the question. My mind was blurred by the question. :) The question is very tricky. Why? Because in the question ...
Zollie's user avatar
  • 2,946
3 votes
Accepted

iFrame with javascript

Firstly, your Javascript contains an error so it won't run at all. Specifically you're missing a ) near the end. Secondly, Google send a X-Frame-Options: SAMEORIGIN header, basically meaning you ...
Lodder's user avatar
  • 26.9k
3 votes

Link to Page & Pre-Filter Portfolio Items

By "anchor and jquery" you mean like the way bootstrap tabs work - ie. by letting the uri's fragment hit the id of the tab. But these tabs aren't set up like that. You can of course use jquery to ...
jamesgarrett's user avatar
  • 3,319
3 votes
Accepted

Link to Page & Pre-Filter Portfolio Items

I found the answer, thanks for the help @jamesgarrett The tabs were using shuffle.js so I needed to edit the page builder js file. jQuery(function($) { var $container = $('.sp-simpleportfolio-...
jonboy's user avatar
  • 3,613
3 votes
Accepted

Send error or exception returned from ajax request to enqueuemessage

When you say "display it into enqueuemessage" I'm assuming that you want to display it in the same message area that enqueueMessage displays in. You can do that in your javascript by calling Joomla....
Robbie Jackson's user avatar
3 votes
Accepted

Joomla site overrides Array.from() causing Google Maps JavaScript API v3 to not work correctly

I had the same issue - Google Maps doesn't like the combination of Mootools (enabled in my Template) and Progressive Cache (enabled in Joomla Global Config) Luckily, I could disable Mootools in my ...
Adrian Diehm's user avatar
3 votes
Accepted

How to show multidimensional data in my CanvasJS chart?

Your original coding attempt is repeatedly overwriting the $dataPoints variable inside of the loop -- this is why you only see the last iteration's data. To create the desired multidimensional array ...
mickmackusa's user avatar
  • 4,826
3 votes
Accepted

How is Mootools loaded?

In Joomla it's possible to load JavaScript libraries via different ways, via: your template a component a (system) plugin a module When it's loaded on every page, it's usually loaded via your ...
pe7er's user avatar
  • 2,068

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