Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted June 21, 20222 yr 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, 20222 yr by Mick79
June 21, 20222 yr 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.
June 21, 20222 yr Author 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 🙂
June 21, 20222 yr 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">
June 21, 20222 yr Author 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).
June 21, 20222 yr And you are using \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, ... ); in your controller to load your JS, right?
June 21, 20222 yr Author 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.
June 21, 20222 yr Author 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 🤣
June 21, 20222 yr JS name and its call it's a bit crazy in IPS4. You need the location there: admin, front or global.
June 21, 20222 yr Author \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.
June 21, 20222 yr 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, 20222 yr by Adriano Faria
June 21, 20222 yr 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, 20222 yr by Nathan Explosion
June 21, 20222 yr Author Solution 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:
June 21, 20222 yr 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.