Apr 24th, 2007 ExpressionEngine and the Power of URL Segments
I had need today to serve a separated RSS feed of just my blog articles — sans links and quick-posts. At first I thought I’d simply duplicate my RSS template and call it something like rss-blog.php.
Yeah right. Not with ExpressionEngine and its support for URL segment conditionals around. Ladies and gentlemen, pay attention, because this is all it took: if segment_3 != 'blog'
Now, the when the URL is http://seansperte.com/rss/blog I can show unique content by placing it inside the if statement, like so:
- weblog="blog1{if segment_3 != 'blog'}|blog2{/if}"
See how that works? See how easy?
Sean Sperte is Geek & Mild. His passion for technology and media, along with his interest in
Comments
Sean
April 24, 2007
Okay, I should probably explain a little more.
Basically the
weblogparameter allows for multiple values (as I’ve discussed before ), but I don’t want the second value (seanasides) when the URL ends in /blog. To do this I use the “does not equal” symbol (!=) to test the URL.So, in English the statement says: if the third segment of the URL does not equal “blog”, then put
|seanasides.(And I should also note that because of this, it’s now possible to pick up a posts-only version of my RSS feed … for those that care to.)
Sean
April 24, 2007
Oh, and by the way, I did today that with Coda . ;)
David Russell
April 30, 2007
Sean: The power of controlling content with the URL segment is one of those things that I really love about EE. It’s definitely one of those features worth highlighting for others.
Comments are closed.