[New Extension] Sarge: Drop-down field enhancer
Posted: 04 April 2008 01:26 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  117
Joined  01-02-2008

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!

 Signature 

Brandon Kelly
brandon-kelly.com
twitter.com/brandonkelly

Profile
 
 
Posted: 04 April 2008 01:31 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

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 smile

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 04 April 2008 01:57 AM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

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 wink

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!! wink

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 04 April 2008 01:02 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  117
Joined  01-02-2008
Cocoaholic - 04 April 2008 01:31 AM

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.

 Signature 

Brandon Kelly
brandon-kelly.com
twitter.com/brandonkelly

Profile
 
 
Posted: 04 April 2008 05:58 PM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1077
Joined  01-24-2006

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

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 04 April 2008 06:04 PM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006
brandon.kelly - 04 April 2008 01:02 PM

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 wink

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!! wink

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

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 04 April 2008 10:40 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  326
Joined  03-18-2007

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?

Profile
 
 
Posted: 05 April 2008 03:54 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1593
Joined  01-05-2007

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

Great extension!

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
Posted: 05 April 2008 03:59 AM   [ Ignore ]   [ # 8 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

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

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 April 2008 07:52 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  117
Joined  01-02-2008
Mark Bowen - 05 April 2008 03:59 AM

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.  grin

 Signature 

Brandon Kelly
brandon-kelly.com
twitter.com/brandonkelly

Profile
 
 
Posted: 05 April 2008 08:02 AM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

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! wink

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 April 2008 08:06 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  117
Joined  01-02-2008
slapshotw - 04 April 2008 10:40 PM

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.

Image Attachments
nci-office-locations.jpg
Click thumbnail to see full-size image
 Signature 

Brandon Kelly
brandon-kelly.com
twitter.com/brandonkelly

Profile
 
 
Posted: 15 June 2008 08:02 AM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

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.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 15 June 2008 09:40 AM   [ Ignore ]   [ # 13 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  117
Joined  01-02-2008
mdesign - 15 June 2008 08:02 AM

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.

 Signature 

Brandon Kelly
brandon-kelly.com
twitter.com/brandonkelly

Profile
 
 
Posted: 15 June 2008 07:24 PM   [ Ignore ]   [ # 14 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

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.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 15 June 2008 09:49 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  117
Joined  01-02-2008

OK… I had thought about that but saw a limitation (I’d have no way of knowing if a row further down the line should be selected or not), but I suppose I could have something like that apply only if the fields value is null.

The only issue would be that if you want to select an option without a value, every time you come back to the Edit form you’d have to reselect that option. Although I have a feeling if you’re using the ‘default option’ feature, you probably won’t have any options that have no value to begin with.

 Signature 

Brandon Kelly
brandon-kelly.com
twitter.com/brandonkelly

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65087 Total Logged-in Users: 39
Total Topics: 82227 Total Anonymous Users: 23
Total Replies: 441925 Total Guests: 224
Total Posts: 524152    
Members ( View Memberlist )