This simple 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/
Hi Tony,
Nice little extension well done and thanks for sharing. Reminds me of the plugin I made a while back although a global variable is a great addition.
Best wishes,
Mark
Nice one Tony!
I have been using something very similar myself and ‘translated’ to your extension it looks like this: (shortest version I could come up with)
function set_last_segment()
{
global $IN;
$IN->global_vars['last_segment'] = end($IN->SEGS);
}
Your extension seems to also list ‘index.php’ as a last segment, the code above does not.
Cheers, Elwin
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.