Jump to content

CodingJungle

Members
  • Posts

    3,066
  • Joined

  • Days Won

    31

Community Answers

  1. CodingJungle's post in Check if we're on the main board page was marked as the answer   
    plus \IPS\Dispatcher already loads these values:
    $app = null; $module = null; if(\IPS\Dispatcher::hasInstance()){ $dispatcher = \IPS\Dispatcher::i(); $app = $dispatcher->application; $module = $dispatcher->module; } if($app !== null && $app->default && $module->default){ //if we are here, we on the default app/module, lets do our thing }  
  2. CodingJungle's post in Theme Hook weirdness in 4.6 was marked as the answer   
    @Adriano Faria its not 4.6 that is at fault per se, IPS is at some fault here due to the way they engineered how the theme hooks work, but it's the latest php 7.4 and 8.0 that is the issue.
    example:
    <?php class myclass { public function myfunction(){ return parent::myfunction(); } } this will error out on the new versions of 7.4 and 8.0, cause myclass isn't a child class of anything, so there is no parent to call. 
    the theme hooks get eval'ed as stand alone classes, they replaced the " extends _HOOK_FILE" with "_tmp" (same with parent::hookData() gets replaced with array() ), so the class would be something like class my_theme_hook_temp {}. during the eval process, it it validating the code and that validation is failing on anything with parent::myfunction() that is being called in the code, that is why the call_user_func_array is working for toolbox, cause it passes the validation, so the template will build. 
    so its not the parent::hookData() that i original thought it was, cause i just took a cursory look at the code, patched my files, it seemed to work cause my datastore wasn't cleared, but as soon as it cleared, i got that error. 
    so in any template overrides you are doing, you need to wrap it with a if(\is_callable('parent::myfunction')){} and then inside the if statement, call the parent method with:
    return \call_user_func_array( 'parent::' . __FUNCTION__, \func_get_args() ); like i have done in the example hook i posted a few post up. if you need further help, send me the app, and i will make the changes so you can see within your code what i'm talking about 🙂
  3. CodingJungle's post in Intellij IDE support was marked as the answer   
    https://github.com/codingjungle/toolbox
    you can grab it from here, make sure you checkout the dev branch as it is the most up to date. 
  4. CodingJungle's post in React with IPS4 was marked as the answer   
    if this for a non-marketplace app, i would load it up thru the interface folder or load it remotely.
    $myJs = \IPS\Output::i()->js('myfolder/myjs.js', 'myapp','interface'); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles,$myJs); or 
    \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles,[ \IPS\Http\Url::external('http://example.com/something.js') ]); if this is for a MP app, you might have to consider the remote loading as an option, since last i heard the the interface folder doesn't work for the cloud communities and i don't think you can you use the bypass method (which would be loading it thru the resources), cause it probably wont be able to properly map the imports (as imports if i am not mistaken are loaded by relative paths and resources wouldn't be relative). 
×
×
  • Create New...