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 Plugin! Slashee (add/remove slashes to get urls how you want)

Development and Programming

timkelty's avatar
timkelty
177 posts
16 years ago
timkelty's avatar timkelty

I’m proud to present Slashee, an plugin that allows you to add/remove leading/trailing slashes to a string (primarily, URLS).

Written by Karl Swedberg: englishrules.com | karlswedberg.com with help from me, Tim Kelty: geniuscar.com …Karl did all the real work, though. We’re both happy employees at Fusionary.

So essentially it works like this:

{exp:slashee start="remove"}/path/to/file{/exp:slashee}

Result: path/to/file

{exp:slashee start="remove" end="remove"}/path/to/file{/exp:slashee}

Result: path/to/file

{exp:slashee start="add" end="remove"}path/to/file{/exp:slashee}

Result: /path/to/file

How I use this Sometimes a client may need to enter a link or path, and we don’t know if they are going to include leading or trailing slashes. If we use that field to assemble a URL at some point with other segments, we might end up with something like http://site.com//path/to/file, if we use Slashee, we always get the URLs how we want.

For example: I often have a “Miscellaneous Content” weblog, with a title and body field. In order for that content to be used in a site search, I also include an optional “Search URL path” field. That way in my search results template I can have a conditional that uses that field instead of an auto_path for items in the Miscellaneous Content weblog. I also display the url at the bottom by assembling something like {homepage}{misc_search_url_field}. I use Slashee to make sure we don’t get extra slashes in there, (http://site.com//path/to/file)

Simple but useful, for me anyway! Enjoy.

       
Lost Cause's avatar
Lost Cause
9 posts
16 years ago
Lost Cause's avatar Lost Cause

Nice and clean, I like it.

       
timkelty's avatar
timkelty
177 posts
16 years ago
timkelty's avatar timkelty

Updated. It now will no longer add a slash at the beginning if the string starts with a http:, https: or #

       

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.