Quickie ExpressionEngine Plugin: URI Prettify
Posted on 08. Sep, 2009 by Jack in Development, ExpressionEngine
I really don’t have a good place to post this stuff right now as a blog is hardly ideal for storing ExpressionEngine addons, but until I get my real site up, this will have to do.
I whipped up this little plugin because I kept getting pinned into a corner when using Categories. For example, if an entry is part of more than 1 category, Blue and Red as subgroups of a Colors parent group for instance, and you’d like to list all entries in the Red subcategory… well good luck.
{categories limit="1"}{category_name}{/categories}
This will give you “Colors”. Not what we’re going for.
{categories limit="2" backspace='2'}{category_name} -{/categories}
Will give you “Colors – Red“, which will work, unless one of your entries is also in Blue. Since the categories are listed alphabetically, you end up with “Colors – Blue” even though your url is http://site.com/section/category/red”.
Well, why not just take the URI segment and case modify it to say “Red”? Easy enough, as long as your URI segments match the name. So I wrote a plugin to take any string, such as {segment_3}, and strip out the “_” or “-” delimiters and set words to title case. Parameters exist to uncapitalize words such as “and”, “for” and “the”. Give it a try, it just might come in handy in a pinch. Full documentation is in the plugin’s “Usage” area, which you can see in the Plugin Manager of your ExpressionEngine Control Panel, but here’s a quick example usage:
<title>{site_name} | {exp:uri_prettify uncap_keywords="yes" keywords="and|to|the|milk"}{segment_1}{if segment_2} | {segment_2}{/if} {/exp:uri_prettify}</title>
Download URI Prettify v1.0.

5 Comments
Garrett Winder
08. Sep, 2009
I like the way your head thinks. I’ll have to give this a try. Thanks!
Jim Arment
11. Sep, 2009
This looks great! I already know of two site where I plan on implementing this.
Thanks!
Andrew Philpott
15. Oct, 2009
This is awesome. Thank you so much!
Sean
18. Nov, 2009
Jack,
I was using find and replace to get rid of the underscores, but this is much better. Just installed it and it works perfectly. I would suggesting adding “is|a” to the default list of keywords.
Mark
26. Dec, 2009
Hi,
When I’m using your plugin within exp:weblog:entries it doesn’t render anything.
{exp:weblog:entries weblog=”movies” search:movie-cast=”{exp:uri_prettify}{segment_3}{/exp:uri_prettify}” dynamic=”off”}
but when i’m putting the value manually then it works.
Please advice.
Leave a reply