Mick23 Posted June 21, 2022 Posted June 21, 2022 (edited) Hi folks, My application that is working in my dev environment is behaving differently (ie: not at all) when "installed" in the live environment. I realise that I may be missing some configuration steps here so please bear with me. I downloaded a new build of my application from the developer centre I uploaded the .tar file to my live applications directory I extracted the file into a directory of its own From the admin cp, I installed the application as it was now visible in the list Installation did not show any errors Going to the game page I do not get any php or javascript errors, and using the inspector shows that the javascript did not appear to run. Part of the page where there is supposed to be an image and a label that shows one of the template parameters. I should be seeing: Instead I see: Cheers! Mick Edited June 21, 2022 by Mick79
Adriano Faria Posted June 21, 2022 Posted June 21, 2022 3 minutes ago, Mick79 said: I uploaded the .tar file to my live applications directory I extracted the file into a directory of its own From the admin cp, I installed the application as it was now visible in the list Not the problem you're facing but you don't need to do this. Simply install the app by upload the .tar directly in the ACP -> System -> Applications page.
Mick23 Posted June 21, 2022 Author Posted June 21, 2022 2 minutes ago, Adriano Faria said: Not the problem you're facing but you don't need to do this. Simply install the app by upload the .tar directly in the ACP -> System -> Applications page. My web host has a really annoying spam filter that gives me 403 errors when I try to do this, so for now it's a workaround 🙂
Adriano Faria Posted June 21, 2022 Posted June 21, 2022 Did you added your image into "front" folder in dev/resources? And to call: <img src='{resource="your_image.jpg" app="appKey" location="front"}' class="something"> Mick23 1
Mick23 Posted June 21, 2022 Author Posted June 21, 2022 Yes I did, thanks. I just used the inspector and can see that the images are present, but not visible (as the visibility of the image element is toggled based on a condition in the javascript. So that's one mystery solved 🙂 The first line of my initialise function is: initialize: function () { this._phrase = ips.getSetting('phrase'); ... } On dev this works fine, on my live env it does not appear to run at all. I'll put some console.log calls in to see if I can see where it's dying (or if it's executing at all).
Adriano Faria Posted June 21, 2022 Posted June 21, 2022 And you are using \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, ... ); in your controller to load your JS, right?
Mick23 Posted June 21, 2022 Author Posted June 21, 2022 Sure is: \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('gameplay.js', 'hangman', 'gameplay')); What's baffling me is why it wouldn't work on the live env vs the dev one. I added some console logs in initalize() that work on live but not on dev.
Mick23 Posted June 21, 2022 Author Posted June 21, 2022 It may be that my dev/js folder structure is not correct: /dev/js/gameplay.js I do not have the "front" subfolder that is present with css files. Is this an issue? I have noticed that the docs state: For example, if we created javascript files in dev/js/front/mygroup/somefile.js, then the bundle name would be front_mygroup.js (location, underscore, groupname), and loaded as follows: \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_mygroup.js', 'app', 'location' ) ); But I am not using the underscored bundle name, I don't think? Maybe I just need to sleep on it, it's been a long day already 🤣
Adriano Faria Posted June 21, 2022 Posted June 21, 2022 JS name and its call it's a bit crazy in IPS4. You need the location there: admin, front or global. Mick23 1
Mick23 Posted June 21, 2022 Author Posted June 21, 2022 \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('gameplay.js', 'hangman', 'front')); With the file at /dev/js/front/gameplay.js - the above works on dev, fails on live. If I add the change it to 'front_gameplay.js' then it fails on dev and live.
Adriano Faria Posted June 21, 2022 Posted June 21, 2022 (edited) See this example: File: applications/volunteer/dev/js/front/controllers/search/ips.volunteer.search.js Call: \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_search.js', 'volunteer', 'front' ) ); Edited June 21, 2022 by Adriano Faria
Nathan Explosion Posted June 21, 2022 Posted June 21, 2022 (edited) Move the js to a folder as follows-> /dev/js/front/banana/controllers/gameplay.js \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_banana', 'hangman', 'front')); Refer to the main IPS code - do a search of the files in your IDE for \IPS\Output::i()->js( and then match up what you see in that to what you see in that apps /dev/js/ folder, and things become clearer (the addition of 'controllers' and 'templates' in to the mix doesn't appear covered in documentation) Edited June 21, 2022 by Nathan Explosion
Solution Mick23 Posted June 21, 2022 Author Solution Posted June 21, 2022 I figured it out, the front/controllers/... folder structure is required for the files to compile properly: This code now works with gameplay.js in the gameplay folder: \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_gameplay.js', 'hangman', 'front')); Thank you all for your assistance 🙂 This was the thread that tipped me off:
Adriano Faria Posted June 21, 2022 Posted June 21, 2022 2 minutes ago, Mick79 said: I figured it out, the front/controllers/... folder structure is required for the files to compile properly: Oh yes... I fixed mine. May help someone someday. Mick23 1
Recommended Posts