Jump to content

disable/enable plugin for settings changes to take effect


Chatwee

Recommended Posts

Posted

Hello,

I've recently created a plugin and it works as expected - as long as I test it in my local enviroment (dev mode enabled). After installing it on the actual community site, it seems that I have to disable the plugin and then enable it again for any changes in the 'edit' section to take effect. Do you guys have any suggestions on what might be causing this issue and how I can fix it?

Thanks

 

 

Posted

How are you handing the settings? Are you only updating the database table?
This won't be enough, you'll also need to trigger the cache rebuild 

\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $v ), array( 'conf_key=?', $k ) );
unset( \IPS\Data\Store::i()->settings );

 

Posted

Thank you for your answers.

 

@CP_User

Yes, clearing the cache works, but I have to do it everytime I change the settings. Disabling/enabling the plugin takes less time, though ;)

 

@Adriano Faria

Yes, this is exactly what I mean and yes, all of them have deafult values.

 

@Daniel F

This is the way I am handling the settings:

$form->add( new \IPS\Helpers\Form\Checkbox( 'setting1', \IPS\Settings::i()->setting1, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'setting1' ) ) );
$form->add( new \IPS\Helpers\Form\Textarea( 'setting2', \IPS\Settings::i()->setting2, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'setting2' ) ) );
$form->add( new \IPS\Helpers\Form\Checkbox( 'setting3', \IPS\Settings::i()->setting3, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'setting3' ) ) );

if ( $values = $form->values() )
{
	$form->saveAsSettings();
	return TRUE;
}

return $form;

 

Any suggestions?

Posted

Try changing the code to the following:

$form->saveAsSettings( $values );

Also, the options you're passing in are incorrect for those form field types. app, key, and autoSaveKey are for Editor type or Translatable only.

Posted

@HeadStand

Thank you for the suggestions.

It turns out that this issue was being caused by me using the  \IPS\Theme\class_core_front_global hook incorrectly.

 

Thank you all very much

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...