Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Checkbox for plugin install_options

Quote Reply
Checkbox for plugin install_options
I am having the hardest time figuring out a stupid checkbox Unsure
I can't find ANY info on this.

This version doesn't "stick" in config options when I update settings(check or uncheck the box) and then "update", the checkbox always reverts to orig setting.
Code:
$mgr->install_options('ZipCodeSearch', [['use_cat_dropdown', '1', '', 'CHECKBOX', ['name'], ['1'], '']]);


This version "sticks" in config options, but when I use tag <%use_cat_dropdown%> in my page it shows '1' when the box is checked, and ARRAY(0x8404438) when it is unchecked.
Code:
$mgr->install_options('ZipCodeSearch', [['use_cat_dropdown', '1', '', 'CHECKBOX', ['name'], ['value'], '']]);

All I really want is a checkbox and a way to retrieve its setting from within a template.

I have no CHECKBOX examples other than the one I created with wizard, but without any docs (that I can find),
I don't even know what the Wizards form fields expect wrt a Checkbox.

Thanks for any help
Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Checkbox for plugin install_options In reply to
i'm confused as to what you are trying to do -- is this in the Admin side form?

Just a thought:

Usually when a passed in parameter becomes an "array" it means that there is more than one of them. Even an unused element in a form will be passed back. If you are doing a "one or the other", make sure to use an <%if%> construct to only allow one such element per form. Each check-box should have it's own name -- unlike radio buttons which are all the "same" (since only _one_ can be set at any given time).


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Checkbox for plugin install_options In reply to
This is on the admin side.
After you install a plugin, you get "edit" on wizard page.
Edit brings up that plugin's options.

I want an option with a check box there.

Then on a template I want to check the value of the checkbox, if it's checked do 1 thing, if not do something else.

So, I want a plugin option checkbox and a way to retrieve its setting from within a template.
I have it working for other options, just not checkboxes.

I am confused about this call... The first '1' is the default value. There is only one other value and that would be 0. It is a checkbox, so there are way too many arguments here :-)

Code:
$mgr->install_options('ZipCodeSearch', [['use_cat_dropdown', '1', '', 'CHECKBOX', ['name'], ['1'], '']]);

What I think is going on is that if the checkbox is 'off', use_cat_dropdown doesn't exist?
If that's the case can I first check to see if it exists, like this?
<%if use_cat_dropdown = '1'%>
do something
<%else%>
do something else
<%endif%>

or something along those lines?
I can just use a damn radio button, but come on, we should be able to use a single checkbox :-)

Thanks
Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Checkbox for plugin install_options In reply to
I wouldn't bother trying to figure it out unless you really need a checkbox. Just use a select Yes/No instead. It's all old code that no one's touched in a while and can't really change due to backwards compatibility issues.

Adrian
Quote Reply
Re: [brewt] Checkbox for plugin install_options In reply to
So then I wasted several hours working on this and I have to 'settle' for a radio button, which can have a whole slew of options that can be chosen from, but no on/off huh?

I digress. As of the time of these posts I had given up checkboxes anyways.


How about another install_option question, (so I don't have to start a new post)...
I want to have a plugin option TEXTAREA that has a global in it.
Code:
$mgr->install_options ('ZipCodeSearch', [ ['cat_dropdown_global', 'Put global code here', 'If Enable Category Dropdown is checked, this code will be used to display a dropdown category menu on the zipcode_search form.', 'TEXTAREA', [], [], '' ] ] );

If not the global code, how about the 'name' of a global that contains a dropdown category menu.

So what I am really after is an option to add a dropdown category menu to my custom search form.
In the admin plugin setup, if the RADIO button for "Show Category Popup" is set to 1(yes), then I want to display a global dropdown menu on my form template.

Like this
<%if use_cat_dropdown%>
<%cat_dropdown_global%>
<%endif%>

I have this all setup, but if I put <%cat_dropdown_global%> as the text for this option, the tag displays <%cat_dropdown_global%> as text and doesn't run the global. ( I didn't expect that to work).
So I tried using just the name 'cat_dropdown_global' as the text and that didn't work either.

Maybe this could just be a text box. If it is empty, don't display a dropdown category menu.
If it has text in it, it is the name of the global to place on the form.
This will work IF I can turn the text into a global while on the template.

If I have to (maybe only way), I just write a subroutine in my plugin and call that like this

<%if use_cat_dropdown%>
<%Plugins::ZipCodeSearch::DisplayCatDropdown%>
<%endif%>

In the subroutine 'DisplayCatDropdown' grab the text from plugin options, and if it is not an empty string,
get and execute(or return) the global.

Please let me know what will work.

Thanks
Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Checkbox for plugin install_options In reply to
Hi,

Something like this?

$mgr->install_options ( 'ZipCodeSearch', [ ['cat_dropdown_global', '1', 'Do you want to turn this feature on?', 'SELECT', ['Yes','No'], ['1','0'], '' ] ] );

That should give you a SELECT box, with a yes/no option. You then just need to get the option option from the plugin (via Links::Plugins->get_plugin_user_cfg). Something like this would probably do it;

my $option = Links::Plugins->get_plugin_user_cfg('ZipCodeSearch')->{'cat_dropdown_global'};

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!