Gossamer Forum
Home : Products : Links 2.0 : Customization :

if else in links.html

Quote Reply
if else in links.html
Hello,

In links 1.11, I modified the site_html.pl so that when there is an url, it makes the title a link. Otherwise, it prints the title alone, like this:

if ($rec{'URL'})
{ $output = qq|
<ul><li><b><a href="$build_jump_url?$db_key=$rec{$db_key}">$rec{'Title'}</a></b>|; }
else
{ $output = qq|
<ul><li><b>$rec{'Title'}</b>|; }

Is this possible with links.html template? If so, how?

Thanks


------------------
Jian Liu
Indiana University Libraries
Quote Reply
Re: if else in links.html In reply to
Yes, it is possible, but you don't do it in links.html. Use sub site_html_link in site_html_templates.pl.

Add the following code just above the "return &load_template" line:

Quote:
my $my_url;

if ($rec{'URL'}) {
$my_url = qq|
<ul><li><b><a href="$build_jump_url?$db_key=$rec{$db_key}">$rec{'Title'}</a></b>|; }
else {
$my_url = qq|
<ul><li><b>$rec{'Title'}</b>|;
}

Then replace:

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

to read:

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

Then, go to links.html and change:

Quote:
<ul><li><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>

to read:

Quote:
<%my_url%>

I hope this helps.

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/


[This message has been edited by Bobsie (edited February 17, 1999).]
Quote Reply
Re: if else in links.html In reply to
It worked again, this time after a little hairing pulling. Now my link.html has:
<ul>
<li><a href="<%db_cgi_url%>/Detailed<%detailed_url%>"><%Title%></a>

</ul>

I had to insert /Detailed there. Otherwise, it won't find the directory. No idea why, but it is working now.

Thanks again

------------------
Jian Liu
Indiana University Libraries
Quote Reply
Re: if else in links.html In reply to
It works like a charm.

Thanks a lot.

------------------
Jian Liu
Indiana University Libraries
Quote Reply
Re: if else in links.html In reply to
If I may impose upon you for one more extension to the above:

I am thinking of extending the change you made so that the title will link directly to the detailed view of each record. For example, right now in my link.html template, I have only:

<%my_url%>
</ul>

I don't have any other external links (URLs) in my database. When people go to the page, they only see the title of each record. I want them to be able to click on the title and the detailed view of that record will be displayed.

Is this doable? If so, how?

Thanks


------------------
Jian Liu
Indiana University Libraries
Quote Reply
Re: if else in links.html In reply to
Sure thing, just change:

<%db_cgi_url%>/jump.cgi?ID=<%ID%>

to

<%detailed_url%> and turn $build_detailed on in links.cfg.

That should do it. I hope this helps.

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/