New Extension: Last Segment
Tom Kiss published a new extension today that makes it very easy to get the last segment of the URL.
This little extension creates a new global variable which renders the fetches the current last segment in a URL.
The addition of a {last_segment} variable can be extremely useful for a number of reasons. The main benefit is that it allows you to create the appearance of sub-templates and hierarchical page structures. For example, you could have a ‘pages’ weblog and by setting the url_title parameter of the weblog:entries tag to {last_segment}, create a structure of: /head/shoulders/knees/toes/
Why use this when you can fetch the segment using {segment_x}? Well, because this way you can fetch the last segment without even knowing the segment number. This is handy for embedded templates that are shared across site templates and where the segment count will vary.
All in all, a handy extension that should help you make your templates even more reusable.
I briefly tested this extension in my local sandbox and it worked as expected. The extension is a free download and available now: Last Segment by Tom Kiss
Share on Twitter