We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

select_generator turns newlines into <select>s

Development and Programming

Robert Wallis's avatar
Robert Wallis
36 posts
17 years ago
Robert Wallis's avatar Robert Wallis

Here’s a new plugin I just made a minute ago. It will take plain text and turn it into a <select> drop down box. This is useful for when you need to have the customer populate a drop down, but they are afraid of learning HTML.

{exp:select_generator name="month" onChange="alert('changed');"}
1:January
2:February
Other
{/exp:select_generator}
  • Any attributes sent to the plugin EE tag are duplicated in the <select> tag.
  • New lines separate <option>s.
  • Colon : characters separate value from display. value:Display Value
  • Blank lines are ignored.

Have fun!

Update: * Use # in the value to make a new <optgroup>. * Use (selected) in the value to select an item. * Submitted form data will be compared with the values and will automatically select the appropriate <option>s.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Robert,

Looks like this could be a nice addition to EE for clients but have just tried installing it and it doesn’t appear to appear in the installed Plugins list.

I don’t think I have done anything wrong. This was on a fresh install of EE 1.6.1 on a local dev install.

Best wishes,

Mark

P.S. How exactly would people use this plugin? Would you just have a custom text-area field and get the client to place their items in that? At the moment the code you show above shows the plugin code wrapped around items but I guess you would just place the custom field code where they are at the moment?

       
Robert Wallis's avatar
Robert Wallis
36 posts
17 years ago
Robert Wallis's avatar Robert Wallis

Sorry you can’t see it in your plugin manager, I just downloaded the one I uploaded and tried it, and it works for me. But I’m using 1.6 because I’m too lazy to update. Please let me know if you figure it out.

You are exactly right with the intended usage, make a custom weblog field, and put that inside the EE tag instead of the text in the example.

       
Robert Wallis's avatar
Robert Wallis
36 posts
17 years ago
Robert Wallis's avatar Robert Wallis

Thank you Victor for the # idea, I was trying to figure out how to do that in a friendly way.

I also added “selected” support in two ways: 1) If you type (selected) before an entry it will select it. 2) Any form data submitted to the page will select the appropriate options.

{exp:select_generator name="test_name" id="test_id" onChange="alert('changed');"}
Regular Entry
#:numbers
(selected)1:One
2:Two
#:states
ca:California
nv:Nevada
{/exp:select_generator}

I’m not adding disabling right now 😊 I’m tired and I need to work in a few hours. And I think I’ll use the Google 70% rule here and say that 70% of the people using this plugin won’t care about disabling options.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Robert,

I am using 1.6.1 at the moment. Not too sure if that has anything to do with it?

Will try the latest update that you have attached.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Robert,

Just tried this on another brand new 1.6.1 install and it still doesn’t show I’m afraid! :-(

Would be great to get this working with 1.6.1 if possible.

Best wishes,

Mark

       
Robert Wallis's avatar
Robert Wallis
36 posts
17 years ago
Robert Wallis's avatar Robert Wallis

I just tested it on a site running 1.6.1 that we did, and it shows up in the Plugin Manager. It’s called “Select Generator” by the way.

It’s my first plugin, so I don’t know why a plugin wouldn’t show up, and it shows up on two separate machines running different versions of EE. So I’m sorry, I don’t know how to help.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Robert,

I don’t understand it either. I have now tried another 3 times and it still doesn’t show up for some reason. I tried it on an older V1.5.2 of EE and it came up fine but every time I install a brand new 1.6.1 on my localhost it doesn’t work.

I will take a look at this again a bit later on and see if I am doing something silly. Pretty sure I’m not though.

Maybe anyone else who downloads this and tries it out on 1.6.1 - 20071113 could let us know how it goes for them?

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Victor,

Must be me then!! :-(

Have tried so many times now though and I know for a fact that I am installing it all correctly. Maybe this doesn’t work well on a localhost install?

The V1.5.2 that I tried it on was on an actual web-server but all the 1.6.1 installs are on MAMP on OSX.

Will maybe try a bit later on with a web-server install and let you know how it goes.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Robert,

Just to let you know that I found out what it was in the end. When I download your plugin the permissions are set a little odd when I unzip it. Usually on MAMP I just pop the plugin into the plugins folder and it all works fine. This however needed me to get info on it and set some permissions first as it had no access set on it.

It now shows up fine in the plugins manager. Going to try it out now!! 😊

Thanks again.

Best wishes,

Mark

       
Robert Wallis's avatar
Robert Wallis
36 posts
17 years ago
Robert Wallis's avatar Robert Wallis

Victor: Yes, if you wanted a blank value you just start the line with a colon.

:(please choose a state)
AK:Alaska
AZ:Arizona
CA:California

Mark: Glad you got it working, thanks for the update.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.