Soma Posted April 2, 2014 Posted April 2, 2014 I did it again http://soma.urlich.ch/posts/custom-js-in-processwire-admin/ 14
Joss Posted April 2, 2014 Posted April 2, 2014 Ah, some nice reading to go with my coffee in the morning! Ta, bruv.... 1
Martijn Geerts Posted April 3, 2014 Posted April 3, 2014 You should do it more often @PapaBear: what the hell is "Ta, bruv...." 1
kongondo Posted April 3, 2014 Posted April 3, 2014 ...@PapaBear: what the hell is "Ta, bruv...." @Martijn...your holiday to the UK is long overdue then!!! 2
Soma Posted April 12, 2014 Author Posted April 12, 2014 I had to rewrite some of the tutorial for adding a script in admin.php. Due to some effect of an installed third party module, the custom script was added after Jquery core js. This usually isn't the case when adding a script via admin.php. I wasn't aware of it at that time and only later remembered that adding a script the way I proposed in admin.php will add our script BEFORE the jquery core script in admin, thus not working when using $ jquery syntax. It's simply because of the order the JS's get added. After investigating, I found the third party module that was, for some reason, changing this behavior. Reason was: it was loading the JqueryCore in the init() method, thus resulting in my script getting added after JqueryCore. I've changed the tutorial to account for this simply by calling the JqueryCore module before adding the custom JS. So instead you would have to do it like this to make sure it gets added after JqueryCore js. $modules->get('JqueryCore'); $config->scripts->add($config->urls->templates . "scripts/scroll.js"); Sorry for the confusion. 2
NorbertH Posted August 24, 2018 Posted August 24, 2018 As $config-scripts is a wire array objekt wouldnt it be easier to use : WireArray::prepend() WireArray::append() to controll if the new script is loaded first or last ?
elabx Posted August 30, 2018 Posted August 30, 2018 On 8/24/2018 at 4:07 AM, NorbertH said: As $config-scripts is a wire array objekt wouldnt it be easier to use : WireArray::prepend() WireArray::append() to controll if the new script is loaded first or last ? I was surprised to find out that these are not WireArray! https://github.com/processwire/processwire/blob/master/wire/core/FilenameArray.php
NorbertH Posted August 31, 2018 Posted August 31, 2018 But still they got an append() and prepend() method ... prepend() even seems to remove files that are already in the original array , maybe that would be a nice feature for append () too? Maybe even an option to add custom keys , not just those md5 strings maybe like add($filename, $customkey). That would allow to make a method to add after a certain key like addAfter ($filename, $customkey, $afterkey). That would make it possible to add scripts in an nicely defined order.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now