Search
Other ReReplacer questions
Forum

ReReplacer doesn't work in <script></script> tags.

Fabio Donna's Avatar Fabio Donna
Hi, I'm trying to use ReReplacer 12.8.3PRO in <script></script> tags but it doesn't work.

This is my situation:
<script async src="/pathtomyscripts/scripts.min.js?v={replacer lastupdate}"></script>

should be replaced by
<script async src="/pathtomyscripts/scripts.min.js?v=202306141734"></script>

but instead this one is produced:
<script async src="/pathtomyscripts/scripts.min.js?v=%7Breplacer%20lastupdate%7D"></script>

Please note that the same "trick" works for other tags:
<style>@import url('/pathtomyscripts/master.min.css?v={replacer lastupdate}');</style>

correctly outputs
<style>@import url('/pathtomyscripts/master.min.css?v=202306141734');</style>


Would you help me please?
Thank you very much!
Regards
Peter van Westen's Avatar Peter van Westen ADMIN
It is probably due to the system plugin ordering. Try changing the ordering of the plugins in question.
See: regularlabs.com/blog/242-plugin-order-is-important
Please post a rating at the Joomla! Extensions Directory
Fabio Donna's Avatar Fabio Donna
Hi, thank you for your reply.
I've tried to move ReReplacer system plugin to first position (and cleared cache of course) but the result has not changed.
Just to be sure, I've also tried to move it to last position with same results.
Peter van Westen's Avatar Peter van Westen ADMIN
I could try and look into it... but why not use Joomla's own methods to add scripts with the media version?
$wa = \Joomla\CMS\Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerAndUseScript('myscript', '/pathtomyscripts/scripts.min.js', ['version' => 'auto'], ['async' => true, 'defer' => true]);
Please post a rating at the Joomla! Extensions Directory
Fabio Donna's Avatar Fabio Donna
Thank you for your suggestion but the method I used can be easily modified by others simply changing the head section in template's editor (Helix Ultimate) while changing php code is much more "delicate".

Thanks!!!
Peter van Westen's Avatar Peter van Westen ADMIN
Can you give me (super) admin and (s)ftp access so I can take a look?
And tell me on what url I can see/reproduce the issue.
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Please post a rating at the Joomla! Extensions Directory
Fabio Donna's Avatar Fabio Donna
Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
So where excactly do you place these <script> tags? Where in the administrator can I find this?
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
So I think I found this. It looks like Helix is parsing that text before pushing it on to the plugins. So ReReplacer never gets to see the original {replacer lastupdate}.

You could update your replacement to simply also handle '%7Breplacer%20lastupdate%7D'.
Please post a rating at the Joomla! Extensions Directory
Fabio Donna's Avatar Fabio Donna
Confidential information:
(hidden)
Fabio Donna's Avatar Fabio Donna
Sorry, I've read your last answer later. Yes, I've done what you suggested and it works.
Thank you!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription