Jump to content


  • Posts

  • Joined

  • Days Won


Community Answers

  1. 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.
    <?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 🙂
  2. CodingJungle's post in Intellij IDE support was marked as the answer   
    you can grab it from here, make sure you checkout the dev branch as it is the most up to date. 
  3. 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). 
  4. CodingJungle's post in Clubs issue was marked as the answer   
    okay for posterity or anyone else who needs to do this, i created a hook for \IPS\Member\Club and overloaded the method "availableNodeTypes" and added the class that is the club container for my app to the array returned by the parent method.
    public static function availableNodeTypes( \IPS\Member $member = null ) { $return = parent::availableNodeTypes( $member ); $return[] = Project::class; return $return; }  
  5. CodingJungle's post in Transactions? was marked as the answer   
    the DB class in IPS extends the mysql class in php.
    you'll need to make sure the table you are wanting transactions to run on, is innodb (afaik, myisam doesn't support transactions).  here is some example code from one of my apps that i use transactions in:
    $db = Db::i(); $db->autocommit(false); $db->begin_transaction(); try{ $names = [ ['name' => 'bar'], ['name' => 'foo' ], ['name' => 'deez'], ['name' => 'froyo']]; foreach( $names as $name ){ $db->insert('some_table', $name ); } $db->commit(); } catch( \Exception $e){ \IPS\Log::debug($e); $db->rollback(); } so the DB class does support transactions, but it doesn't actually sound like you need them. i use them in this app, cause they are importing up to 1 million rows at a time from a csv file, and since there are like 30 databases, this could cause a lot of issues with the relations, so if the importer hit an error, it logs it, and then rolls back the changes, preserving the relations. it was either this or spend 3 days rebuilding the relation data :).
  6. CodingJungle's post in Missing class on certain installs? was marked as the answer   
    it is \IPS\Helpers\Form\Checkbox not CheckBox, that is the only thing i see that could cause it, but it should cause havoc for everyone if that is the reason.
  7. CodingJungle's post in Loading my app css in other apps? was marked as the answer   
    you would need to create a hook into the apps controller execute method (for forums you have the topic.php/forum.php, index.php), so the hook should look something like this:
    public function execute(){ parent::execute(); \IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles,\IPS\Theme::i()->css( 'mycss.css', 'myapp', 'front' ) ); }  
  8. CodingJungle's post in URL Query Timeout was marked as the answer   
    yes, $query->request(10)->get()
    you put the timeout as a parameter for request()
  9. CodingJungle's post in USE operator php was marked as the answer   
    those are both return void methods, all that would do is prevent the react being record (at best).
    if the point is not to show the react/reputation, i would hook into the Adverts (and its Review and Comment, if it has them) class and override the canRate() method and just have it return false, that way the react widget wont even display.
    sorry, canReact() (not canRate())
  10. CodingJungle's post in Plugin uninstall hook/extension point? was marked as the answer   
    in system/Plugins/Plugins.php on line 530:
    if ( file_exists( \IPS\ROOT_PATH . '/plugins/' . $this->location . '/uninstall.php') ) { require_once \IPS\ROOT_PATH . '/plugins/' . $this->location . '/uninstall.php'; } i imagine if you created a uninstall.php in your plugin's root, you could do stuff in it like:
    \IPS\Db::i()->dropColumn( 'mytable', 'myaddedcolumn'); \IPS\Db::i()->dropTable('myaddedtable'); //etc (sorry i don't really make all that many plugins, just apps, and the process is a bit different there).
  11. CodingJungle's post in cURL Request Problems was marked as the answer   
    I believe IPS requires a min. curl version of 7.36, you can tell IPS to use an older version of curl tho. create a constants.php in the root directory (where index.php is) and/or edit an existing one, and add this to it:
    define( 'FORCE_CURL', true);  
  12. CodingJungle's post in Iterate through rows of db query was marked as the answer   
    $posts = \IPS\Db::i()->select('*', 'forums_posts', array('topic_id=?', $topic)); foreach ( $posts as $post ) { // not working? } ->first() will get you the first matching record, and will throw an exception if nothing is to be found. this way, there is no exception throw, it just wont have anything or iterator over. 
  13. CodingJungle's post in UPLOAD type field in 3rd-party resources was marked as the answer   
    foreach ( $this->container()->cfields as $field ) { $helper = $field->buildHelper(); if ( $helper instanceof \IPS\Helpers\Form\Upload ) { $cfields[ "field_{$field->id}" ] = (string) $values[ "downloads_field_{$field->id}" ]; } else { $cfields[ "field_{$field->id}" ] = $helper::stringValue( $values[ "downloads_field_{$field->id}" ] ); } if ( $helper instanceof \IPS\Helpers\Form\Editor ) { $field->claimAttachments( $this->id ); } } this is how downloads saves it custom fields, so they do check to see if it is a upload helper and then cast it as a string like @TheJackal84 been saying to do.
  14. CodingJungle's post in Pass data to JavaScript controller was marked as the answer   
    in your php controller do this:
    \IPS\Output::i()->jsVars['somekey'] = $myVar; this will add it as a JS variable to the <head> of the output. 
  15. CodingJungle's post in Configuring IDE was marked as the answer   
    grab this, install it. once it is installed, run the "proxy classes generator". it will create dummy files that the IDE can read to resolve that issue.
  16. CodingJungle's post in Initial admin menu item is no longer creating was marked as the answer   
    there are a few patches for attached to the release notes, one of them solves an issue when you have E_ALL enabled with IN_DEV it will throw an error preventing admin controllers from being added, so it is probably related (and you are just not getting the error).
  17. CodingJungle's post in Error creating admin controller was marked as the answer   
    they've added them to the release notes.
  • Create New...