Gossamer Forum
Home : Products : Gossamer Links : Discussions :

cutting URL

Quote Reply
cutting URL
I have link likes this
www.mysite.com/site/110/99
www.mysite.com/site/121/99
www.mysite.com/site/411/99

Is someone know a way that a global will return the 99 number.

I mean the URL is like
www.mysite.com/site/y/x
when y in number that change (details ID) and x is not change(catid).
Quote Reply
Re: [nir] cutting URL In reply to
Hi,

Could do it one of 2 ways:

1) Make a new global - get_end_number

Code:
Code:
sub {
my $foo = $_[0];
$foo =~ s/\/$//;
my @tmp = split /\//, $foo;
return $tmp[$#tmp];
}

Call with:

<%get_end_number($URL)%>

...or:


1) Make a new global - get_end_number

Code:

Code:
sub {
if ($_[0]=~ m/\/([0-9]+)/) { return $1; }
}

Call with:

<%get_end_number($URL)%>

Both though do the same thing :)

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: Jun 12, 2008, 4:46 AM
Quote Reply
Re: [Andy] cutting URL In reply to
Hi Andy,
Thanks
The first one doesn't return anything.
In the second there is an error that drop all the global,
Quote Reply
Re: [nir] cutting URL In reply to
Hi,

Mmm.. you sure the URL being passed in doesn't look more like:

url.com/1234/99/

(i.e the / at the end) ???

I've added a couple more lines in - just in case thats what the problem is.

The second global should be fixed too - cos I didn't test them Wink

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] cutting URL In reply to
The global work when I type the actually URL (www.mysite.com/site/121/99) instead if the $URL.
Quote Reply
Re: [nir] cutting URL In reply to
Ok - so what FIELD is this URL in?

Guessing its not in the <%URL%> field then?

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] cutting URL In reply to
Yes, Its Not:)
I was think to use
<%Plugins::ULTRAGlobals::Get_Current_URL()%>
Quote Reply
Re: [nir] cutting URL In reply to
Ok - you've lost me now!

How are you currently showing the URL you gave in your field post?

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] cutting URL In reply to
I successes to solve the problemSmile
<%set URL = Plugins::ULTRAGlobals::Get_Current_URL()%>
<% get_end_number($URL)%>

Thanks for the help
Quote Reply
Re: [nir] cutting URL In reply to
Cool Wink