Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

global to display the last part of the url

Quote Reply
global to display the last part of the url
Hi!

I am searching for a global, perhaps someone can help me.

If I have this

<%loop category_loop%>
<a href="<%URL%>"><%Name%></a>
<%endloop%>

the complete URL is returned (http://www.myDomain.de/...y1/sub_subcategory1/).
But in my system for example sub_subcategory1 is not used in this context. Another domain is routed on this folder, on this other domain category1 and subcategory2 don't exist.
For getting this to work, the global has to return instead of the complete url only "/sub_subcategory1/" (only the last folder, comparable with category_short in URL-form...).

I don't think, this is too difficult, but I have done almost nothing with perl yet and don't get it to work on my own...

thanks for helping, Tina
Quote Reply
Re: [tga] global to display the last part of the url In reply to
Hi,

Something like this should work (untested);

Code:
sub {
my ($pref,$blank,$firsturl,$rest) = split /\//, $_[0];
return $firsturl;
}

<%global_name($URL)%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: May 9, 2005, 11:51 PM
Quote Reply
Re: [Andy] global to display the last part of the url In reply to
Hi!

Thanks for the code.

If I take $last = $1 it filters the correct thing, but if I take $2 or something else, I get no result.

I tried some changed, but I don't know Perl as well as I can find the error...

Can the code be changed, that not the 3rd piece of the URL is taken, but always the last?

Thanks, Tina
Quote Reply
Re: [tga] global to display the last part of the url In reply to
Hi,

Try the modified version :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] global to display the last part of the url In reply to
Hi Andy!

I've modified the code a little bit and now it is working quite fine!!!

Thanks!

Bye, Tina