Jump to content

How can I add a setting to my plugin

Featured Replies

Posted

Hello, I'm trying to create a plugin and I want to add some settings to it.

a9756981289b437194f1eee1a2375d0a.png
I want to add those 2 settings to work something like this

b24a26d99bc830ec3d09ef6ad04c023a.png
But I don't know what code I should add to "Content" because it's seems the {lang= it doesn't work.

  • Community Expert

Read through this example. It should answer everything:

 

  • Author

someone can help me? ?

Unless you show the code from the settings, no.

  • Author

Ok buddy

This is what I have in settings.php in FTP /plugins/name/

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

And this in /plugins/name/dev/html

<ips:template parameters="" />

<i style='color: {setting="color_icon_aws"}' class='fa fa-{setting="shape_icon_aws"}'></i>

Also this is what I have in settings of the plugin

6efcf47b17cb63d3e75c39e15427291e.png
https://gyazo.com/6efcf47b17cb63d3e75c39e15427291e

 

This is what I have in settings.php in FTP /plugins/name/

Nothing else? Show all the code you have in the file.

  • Author
 

Nothing else? Show all the code you have in the file.

Nothing else.

This is in settings.php

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) ); $form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) ); $form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

this is the plugin

<ips:template parameters="" />

<i style='color: {setting="color_icon_aws"}' class='fa fa-{setting="shape_icon_aws"}'></i>

6efcf47b17cb63d3e75c39e15427291e.png&key

those are the settings.

AS I SAID, THEY ARE NOT SAVING.

Like on groups i put 4 and press save, the message "Saved." appears but when i click edit again the 4 is not there.

 

  • Community Expert
 

Nothing else

That's why it isn't saving. You need to have:

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

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

return $form;

 

 

AS I SAID, THEY ARE NOT SAVING.

I KNOW!!!

Where is the saving section of the settings.php? It would explain loads y'see....it's the bit at the end of the settings.rename.php that your plugin has when you create it:

//<?php

$form->add( new \IPS\Helpers\Form\Text( 'plugin_example_setting', \IPS\Settings::i()->plugin_example_setting ) );

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

return $form;

image.thumb.png.4a63f8119dd90e244f41ed39e7c006b9.png

 

  • Author
 

That's why it isn't saving. You need to have:

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

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

 

Lol thanks man im such a noob.

  • Author

@Adriano Faria can i make somehow a color picker?

  • Community Expert
$form->add( new \IPS\Helpers\Form\Color( 'your_setting', \IPS\Settings::i()->your_setting, FALSE ) );

 

  • Author

ty man

  • Community Expert

You can see all fields type on system\Helpers\Form.

  • Author
 

You can see all fields type on system\Helpers\Form.

how can i make if a checkbox is set to no to dont show the icon

Archived

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

Recently Browsing 0

  • No registered users viewing this page.