Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Prevent links from not opening new window.

Quote Reply
Prevent links from not opening new window.
I have edited the links.html file so that it allows me to have people click on links and a new browser opens with a simple target="_link":

<a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"target="_link"><%Title%></a>

My problem is some of my advertiser don't like being opened in a new window (they are listed along with my links - text ads). So somehow I need to put a code in. Preferably a check box on my admin page - "Don't open new window" and a code is generated that prevents the link from opening a new window when clicked. Can anyone come up wit a script that does this?

Quote Reply
Re: Prevent links from not opening new window. In reply to
You don't need an extra script. All you do is the following:

1) Add a field called "isOpen" in the db_def hash in your links.def file, like the following:

Code:
isOpen => [11, 'alpha', 0, 5, 0, 'Yes', 'No|Yes'],

1a) Add the following codes to the %add_system_fields hash:

Code:
isOpen => 'Yes'

1c) Add the following codes to the %db_select_fields hash:

Code:
isOpen => 'Yes,No'

2) Use the "upgrade.pl" file located in a Thread found in the LINKS Modification Forum that will update your existing database with the new field.

3) Then add the following codes to your link.html template file:

Code:
<%if isOpen eq 'Yes'%>
<a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>" target="_link"><%Title%></a>
<%endif%>

AND

Code:
<%if isOpen eq 'No'%>
<a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
<%endif%>

Note: You will need to download the Enhanced Template.pm codes in the Modifications section of LINKS2.0 in the Resource Center for these comparisions to work.

4) Re-build your index.

If you get a Unknown Tag: isOpen, then you will have to add the following codes to your sub site_add_form, sub site add_failure, and sub add_success routines in your site_html_templates.pl file:

Code:
$open = &build_select_field ("isOpen", "$in{'isOpen'}");

AND then in the global variables section (after load template), add the following codes:

Code:
open => $open

Then edit the codes I gave for the template files to the following:

Code:
<%if open eq 'Yes'%>
<a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>" target="_link"><%Title%></a>
<%endif%>

AND

Code:
<%if open eq 'No'%>
<a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
<%endif%>

Regards,

[This message has been edited by Eliot (edited November 08, 1999).]