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

[New Extension] Sarge: Drop-down field enhancer

Development and Programming

Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly

Over the next few days, I’m going to be releasing a few extensions I’ve written for Navigant.

First on the list is Sarge, a simple extension that adds <optgroup> support to the Drop-down List field type, and lets you specify the value of each option.

Example “Select Options” textarea:

Select an option... =

[optgroup] = Group 1
    Option 1 = value_1
    Option 2 = value_2
    Option 3 = value_3
[/optgroup]
Other Option 1 = value_4
Other Option 2 = value_5

Note that specifying each value is optional. If you don’t add an equal sign (=) the option will work just like it would without this extension (the value gets set to the name of the option).

For more information and the download, go to http://brandon-kelly.com/apps/sarge/

Enjoy!

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Nice one Brandon!

I am kind of expecting (hoping) that EE 2 will let you specify the value for each option… We’ll see.

Keep ‘m coming 😊

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

Excellent Brandon,

I’m sure a lot of people are going to find that very handy. I’m off to have a play now in case I can use it on anything 😉

Always like to try out every single extension, module and plugin that there is and see how they all work.

Well done private Brandon. Consider yourself a first-class officer. Atteeeeeeeeeen-tion!! 😉

Best wishes,

Mark

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly
I am kind of expecting (hoping) that EE 2 will let you specify the value for each option… We’ll see.

I wouldn’t be surprised… cp.publish.php already uses their input_select_option method to build the list, which accepts a value parameter.

But this extension was too easy to write to wait around for EE 2.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Its little extensions like this I love!

They just add that little thing missing from the system that comes in handy every now and then.

Well done

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen
But this extension was too easy to write to wait around for EE 2.

Well that’s easier said by someone who knows what they are doing 😉

I for one wouldn’t have even known what that hook was going on about in the first place let alone know what to code to do anything with it!! 😉

Great extension Brandon, thanks again. I’m sure this will come in handy somewhere along the line for me and I would think for a lot of other users too so thanks for that.

Best wishes,

Mark

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
17 years ago
Matt Weinberg's avatar Matt Weinberg

What are people using this extension for? It just affects the Control Panel right? Is it mostly to help the site admins be more organized?

       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

Did anyone else giggle at the big “Powered by Movable Type” Logo in the footer of Brandon’s site?

Great extension!

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

Well I was going to ask about that actually.

Is your site running off Movable Type or are you moving across to ExpressionEngine with it Brandon?

Best wishes,

Mark

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly
Is your site running off Movable Type or are you moving across to ExpressionEngine with it Brandon?

No plans to – let’s just say I’m a “right tool for the job” kind-of-guy. 😊

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

Good enough answer for me but I just use ExpressionEngine for everything nowadays as I know it so well.

Great extension Brandon, keep ‘em coming! 😉

Best wishes,

Mark

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly
What are people using this extension for? It just affects the Control Panel right? Is it mostly to help the site admins be more organized?

It’s mainly for the people that are writing content.

I’m using it for an upcoming section on NavigantConsulting.com that will replace their existing “biography database” site. When we’re done, the professionals will be able to log into the CMS and update their profile, and one of the fields is a drop-down list where they select their Office Location. That drop-down, thanks to this extension, is organized into two optgroups: International and United States. (See attachment)

It’s also helpful on the templating side… All those options that start with “CA -” have their values set such that {p_office} shows everything but the “CA -” part.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

I love this. For example, I always like to show a whole state name in a dropdown, but only store the two-letter code - and this lets me do that easily.

I have a state field where 80% of the entries will be “Michigan”. Any way on the Publish screen to have a default value selected? Would save my client that extra effort of even having to use the dropdown at all.

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly
I love this. For example, I always like to show a whole state name in a dropdown, but only store the two-letter code - and this lets me do that easily.

Glad you like it!

I have a state field where 80% of the entries will be “Michigan”. Any way on the Publish screen to have a default value selected? Would save my client that extra effort of even having to use the dropdown at all.

You could assign Michigan to no value (Michigan = ), and make sure every other option does have a value (including blank rows – or just remove any of those). Not ideal, but that’s probably the only way to do it.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

I was sort of thinking of modding this to look for a “* ” at the front of a line (or something similar), which could output selected=”selected” when it draws that row, but I’m just thinking out loud.

Select an option... =

[optgroup] = Group 1
 Option 1 = value_1
* Option 2 = value_2
 Option 3 = value_3
[/optgroup]
Other Option 1 = value_4
Other Option 2 = value_5

Thanks for this, and your suggestion.

       
1 2

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.