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

converting state abbreviations to full state names in templates

Quote Reply
converting state abbreviations to full state names in templates
In my links2. in site_html_templates.pl I had this sub to convert state abbreviations to full state names to be returned back to my link, category, detailed and other templates.

sub state_name {
my $state = shift;
my %abr = (
AL => "Alabama",
AK => "Alaska",
AZ => "Arizona",
etc.,
WI => "Wisconsin",
WY => "Wyoming",
);
return $abr{$state};
}

Then use in &load_template routines, use
state_full => state_name ($rec{'State'}),

How can I do this in links sql?
Thank you!

Last edited by:

socrates: Nov 11, 2005, 7:00 PM
Quote Reply
Re: [socrates] converting state abbreviations to full state names in templates In reply to
**Bump**

Andy - is there an elegant way to do this? Smile

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] converting state abbreviations to full state names in templates In reply to
Hi Sangiro,

It's easy actually, you don't have to change anything!

Just paste the global code in to template globals:

Code:
sub {
my $state = shift;
my %abr = (
AL => "Alabama",
AK => "Alaska",
etc...
AZ => "Arizona",
WI => "Wisconsin",
WY => "Wyoming"
);
return $abr{$state};
}

Name it state_name, and use it everywhere in templates: <%state_name($State)%>

Hope this helps.

Cheers,
Boris

Facebook, Twitter and Google+ Auth for GLinks and GCommunity | reCAPTCHA for GLinks | Free GLinks Plugins
Quote Reply
Re: [eupos] converting state abbreviations to full state names in templates In reply to
Its so nice having someone else helping out on the forum now as well Angelic

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!
Quote Reply
Re: [Andy] converting state abbreviations to full state names in templates In reply to
Well, thank you both. Wink

Safe swoops
Sangiro