Gossamer Forum
Home : Products : Links 2.0 : Customization :

Hyperlink On/Off Switch and other ?

Quote Reply
Hyperlink On/Off Switch and other ?
Hello all,

First time posting here. I have a few questions.

With the Hyperlink On/Off Switch Mod if I am giving a Link Owner the option of adding a graphic to their listing how would I write the <if statement> so if the owner has a graphic and it is not linked it would display properly, still have the graphic, but not linked?
Also if they do not have a graphic it would show the text either linked <if isLinked = yes> no link <if isLinked = no>

Is it possible to write <if statements> like this?

<%if isLinked%> and <%if Graphic%> then
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>" target="_blank"><img src="<%Graphic%>" width="<%Gwidth%>" height="<%Gheight%>" alt="<%Title%>" border="0"></a>

<%ifnot isLinked%> and <%if Graphic%> then
<img src="<%Graphic%>" width="<%Gwidth%>" height="<%Gheight%>" alt="<%Title%>" border="0"><%endif%>

<%if isLinked%> and <%ifnot Graphic%> then
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"target="_Blank"><%Title%></a><%endif%>
<%ifnot isLinked%><%Title%><%endif%>

What I am trying to find out is can you have multiple <if statements> together?

Larry
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
The better approach is to add the following codes at the top of your sub site_html_link routine:

Code:
if ((isLinked eq "Yes") and (Graphic eq "Yes")) {
$link .= qq|<a href="$db_cgi_url/jump.cgi?ID=$rec{'ID'}" target="_newwin">
<img src="$rec{'Graphic'}" width="$rec{'Gwidth'}" height="$rec{'Gheight'}" alt="$rec{'Title'}" border="0"></a>|;
}
elsif ((isLinked eq "No") and (Graphic eq "Yes")) {
$link .= qq|<img src="$rec{'Graphic'}" width="$rec{'Gwidth'}" height="$rec{'Gheight'}" alt="$rec{'Title'}" border="0">|;
}

elsif ((isLinked eq "Yes") and (Graphic eq "No")) {
$link .= qq|<a href="$db_cgi_url/jump.cgi?ID=$rec{'ID'}"target="_newwin">$rec{'Title'}</a>|;
}
else {
$link .= qq|$rec{'Title'}|;
}

Then define the following tag:

Code:
link => $link

Then add the following tag in your link.html file:

Code:
<%link%>

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


[This message has been edited by AnthroRules (edited April 13, 2000).]
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
Thanks AnthroRules,

I have another question. Say I have a category for Restaurants with sub categories under that.(American, Asian, French, etc.)

What I want to do is have a link to a review of the restaurant. This would be a totally different script. It would allow the user to review this restaurant if they like or read reviews of other people.

Would I create another field in the database and also on the add.html so the person could check if the site is a restaurant. Or somehow set the category Restaurants to automatically add this link.

If I created a separate template for Restaurants added the link to something.cgi?<%ID%> would this work.

Or would it be better to create it similar to this in the sub site_html_link

if ((isFood eq "Yes")) {
$rest .= qq|<a href="location/something.cgi?ID=$rec{'ID'}" target="_newwin">
<img src="review.gif" alt="Review this Restaurant" border="0"></a>|;
}
else {
$rest .= #(Do not know what I would put here. I do not want anything to show if it is not a restaurant)
; }

With above I know I would need to add a field to the database that would not be a problem right?

Larry


[This message has been edited by NewToThis (edited April 13, 2000).]
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
You're welcome...

For your Review question...either download and use one of the Review Mods in the Resource Center or use Widgetz's Review Mod, which is located at the following URL:

http://jsu7785.hypermart.net/review/

BTW: The Resource Center is the first place to check for Modification ideas.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
Might not be the best way but what I have found works for me and might be alittle easier for someone new is:

Code:
<%if isLinked%>
<%if Graphic%>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>" target="_blank"><img src="<%Graphic%>" width="<%Gwidth%>" height="<%Gheight%>" alt="<%Title%>" border="0"></a>
<%endif%>
<%endif%>

<%ifnot isLinked%>
<%if Graphic%>
<img src="<%Graphic%>" width="<%Gwidth%>" height="<%Gheight%>" alt="<%Title%>" border="0">
<%endif%>
<%endif%>

<%if isLinked%>
<%ifnot Graphic%>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"target="_Blank"><%Title%></a>
<%endif%>
<%endif%>

<%ifnot isLinked%>
<%Title%>
<%endif%>

Basically, treat each if/ifnot statement as independent with it's respective endif code.

Hope this helps.
Adam
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
And that is possible with the Enhanced Template.pm, which allows nested if and else (if and ifnot) statements in template files.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
Hi!

I want to use separated Link-Logos with the Link on/off switch.

I changed the SUB site_html_link as following:

sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.

my %rec = @_;

if (($rec{'isLinked'} eq "Yes") and ($rec{'Graphic'} ne '')) {
$logo .= qq|<a href=$db_cgi_url/jump.cgi?ID=$rec{'ID'}><img src=$rec{'Graphic'} width=$rec{'Gwidth'} height=$rec{'Gheight'} alt=$rec{'Title'} border=0></a>|;
}
if (($rec{'isLinked'} eq "No") and ($rec{'Graphic'} ne '')) {
$logo .= qq|<img src="$rec{'Graphic'}" width="$rec{'Gwidth'}" height="$rec{'Gheight'}" alt="$rec{'Title'}" border="0">|;
}
else {
$logo .= qq||;
}

# Set new and pop to either 1 or 0 for templates.

($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals,
logo => $logo
});
}

I think, this should work. But it doesn't. The code returns some strange things - logos in upcounting order to the links. Looks like this:

LINK1: Logo1 - LINK1-description
LINK2: Logo1Logo2 - LINK2-description
LINK3: Logo1Logo2Logo3 - LINK3-description
LINK4: Logo1Logo2Logo3Logo4 - LINK4-description
etc.

What's wrong with my script? I really need some help! Thanx!

Regards,
Norbert

Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
Instead of
Code:
$logo .= qq|(whatever)|;
use
Code:
$logo qq|(whatever)|;
the
Code:
.=
means to concatenate with the previous string value.

--Drew
Quote Reply
Re: Hyperlink On/Off Switch and other ? In reply to
What can I say?

Saying1: THANK YOU!
Saying2: THANK YOU!THANK YOU!
Saying3: THANK YOU!THANK YOU!THANK YOU! :o)

Thanx a lot!

Regards,
Norbert