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

Check if Internal URL or External URL

Quote Reply
Check if Internal URL or External URL
I've setup a Go_To filed in Category DB.
I call this <%Go_To%> somewhere in the categories to direct the user to INTERNAL CATEGORY or EXTERNAL WEBSITE based on what I put as a value in the field.
Now, if I put a value 123 or 12/4/123 in the Go_To field, then the link where I call it from will go to:
<%config.build_root_url%>/<%Go_To%>/index.html .. then becomes
http://www.mydomain.com/12/4/123/index.html which is valid reference to internal category.

but, if I want the link to go to an external site (http://www.yahoo.com/) , then I specify the site URL in Go_To field... but this will cause a dead link
http://www.mydomain.com/http://www.yahoo.com/index.html

My question, what would be the Perl code that I should use inside category.html template to make this work... (I can modify the way I call the Go_To filed... but I do not like this way, then I need to put long URL in the Go_To field...)
something like ...

If the call to an internal page/category (or if it does not start with "http://www") then
<%config.build_root_url%>/<%Go_To%>/index.html
else:
<%Go_To%>
endif;

Thank you
Mark
Quote Reply
Re: [Mark2] Check if Internal URL or External URL In reply to
Hi,

Try:

Code:
<%if URL contains 'http://'%>
<a href="<%config.db_cgi_url%>/jump.cgi?ID=<%ID%>" target="_blank">
<%else%>
<a href="<%config.build_root_url%>/<%URL%>">
<%endif%>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Check if Internal URL or External URL In reply to
 
Sorry Andy... maybe I did not clarify it enough...but where would the [Go_To] field value be read... as I am checking the content of this field to see if it has "LINK ID" or a "CATEGORY ID"

The Go_To field is located in the Category db (when I add category to the db, I specify the value of the Go_To field there: Category > Add ).

Shouldn't I be checking the value of the Go_To field!

can I do something like this.. (but I am missing the right code to do that)
Code:

<%if Go_To contains 'ID='%> /* if Go_To is an internal link in links db so the value in Go_To is something like "ID=143" (the link id) */
<a href="<%config.db_cgi_url%>/jump.cgi?<%Go_To%>" target="_blank">

<%elseif Go_To is a number %> /* if Go_To is a numeric value, then that value is the category_id from categories db */
<a href="<%config.build_root_url%>/<%URL%>">

<%else%> /* go to anywhere specified in the Go_To field... like http://www.yahoo.com/
<%Go_To%>
<%endif%>

Thanks much again ..
Mark
Quote Reply
Re: [Mark2] Check if Internal URL or External URL In reply to
Hi,

I don't think you can do numberical comparisons with the tempalte system (so "is number" wouldn't work =))

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Check if Internal URL or External URL In reply to
Then how do I use your code, but putting Go_To into picture...
Means.. I do not see Go_To in your code, should I replace URL with Go_To in your code.

Thank you
Mark
Quote Reply
Re: [Mark2] Check if Internal URL or External URL In reply to
Can you give me some REAL values, which you have in Go_To? Bit hard to work out really what you are using ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Check if Internal URL or External URL In reply to
I usually put in Go_To something like:
8
then the the link in the category template will look like:
http://www.mydomain.com/8/index.html
(I am using category ids instead of category names when the system runs)

or I put something like this:
13/143

This also means go to category 13/143 in my site...
http://www.mydomain.com/13/143/index.html

but what I want to do is to also allow for external links like: http://www.yahoo.com so if I put this URL in the Go_To field... then the link in the category template will take you to yahoo.com ...
the problem I am calling the Go_To field with <%config.build_root_url%>/<%Go_To%>/index.html
so you see that if I put an external URL, then this link will be killed.

The other thing.... if the external link exists already in the Links DB, then the Go_To field should be able to handle it ... something like jump?id=<%ID%>

So the code that I wrote would be good to use but it is not formatted correctly... any suggestion...

Thanks much Andy..
Mark
Quote Reply
Re: [Mark2] Check if Internal URL or External URL In reply to
This should probably work then:

Code:
<%if Go_To contains 'http://'%>
<a href="<%Go_To%>" target="_blank">
<%else%>
<a href="<%config.build_root_url%>/<%Go_To%>">
<%endif%>

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates