Plugin: URLSafe
Posted: 25 June 2007 10:57 AM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1578
Joined  03-26-2006

Makes a string url safe. Or the reverse. I needed to use this for some friendly category names in a url a while back. With the release of EE 1.6, this might be obsolete, but hey, it might come in handy somewhere as well.

This is a pretty basic plugin. Underscores are replaced with a comma and a space, and hyphens are replaced with spaces.

Place the following tag in any of your templates:

{exp:urlsafe}Sides, Soups, Salads{/exp:urlsafe}
Returns
: sides-soups-salads

{exp
:urlsafe reverse="yes"}sides_soups_salads{/exp:urlsafe}
Returns
: Sides, Soups, Salads

{exp
:urlsafe reverse="yes"}sides-soups-salads{/exp:urlsafe}
Returns
: Sides Soups Salads

PARAMETERS:
The tag has two (optional) parameters:

1. separator: The replacement character [OPTIONAL, defaults to hyphen ’-’]
2. reverse: makes a url safe string in to a capitalized string [OPTIONAL]

The download is now over at its designated page at masugadesign.com:
http://www.masugadesign.com/the-lab/scripts/urlsafe/

 Signature 

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

Profile
 
 
Posted: 25 June 2007 11:05 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  14027
Joined  05-15-2004

When you say “URL-safe”, how does it handle characters which must not appear in a URL? Like, umlauts, ampersands, etc?

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 25 June 2007 11:18 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1089
Joined  03-22-2006

Looking at the code i’d say it has no support for removing/replacing those characters. For true URLsafe’ness why not just urlencode the string? Dirty? that’s a matter of opinion, Safe? yes

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 25 June 2007 11:23 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  14027
Joined  05-15-2004

Yes, urlencoding would be the way to go, I think.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 25 June 2007 11:30 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1578
Joined  03-26-2006

This was put together really quickly for a project that, apparently, didn’t have any wacky characters going on in the Category titles. I think this plugin may be misnamed. All this was supposed to do was take already approved category names and make those quote-enquote “urlsafe”. If you can’t put an umlaut in an EE category name (can you? haven’t tried…), then this didn’t have to bother with it.

So, I think in the interest of this being usable for more than making category names into “url titles” more-or-less (like I said, I think this whole thing might be obsolete now…) it might need an update. I posted this because I thought it was something that might help davenport use category names in the URL as opposed to Cx.

Did this post even make sense? I’m so hungry I can’t think straight.

 Signature 

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

Profile
 
 
Posted: 25 June 2007 11:34 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  14027
Joined  05-15-2004
mdesign - 25 June 2007 11:30 AM
This was put together really quickly for a project that, apparently, didn’t have any wacky characters going on in the Category titles. I think this plugin may be misnamed.

Well, slightly misleading, perhaps ... But I am sure we can have it live up to its name in no time.

If you can’t put an umlaut in an EE category name (can you? haven’t tried…), then this didn’t have to bother with it.

But you can, most definitely.

I’m so hungry I can’t think straight.

Me, too, actually. Off to get something between my teeth.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 22 July 2008 01:43 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  486
Joined  10-14-2005

I wrote a little plug-in yesterday to encode/decode using url or base64…

http://nathanpitman.com/journal/547/expressionengine-plug-in-encodedecode

smile

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

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 10:33 AM
Total Registered Members: 62588 Total Logged-in Users: 10
Total Topics: 77048 Total Anonymous Users: 8
Total Replies: 416160 Total Guests: 138
Total Posts: 493208    
Members ( View Memberlist )
Active Members:    billinteropBud PCrucialeejpJake LymanLeevi Grahamlsatblumichelangelasusansan