Gossamer Forum
Home : Products : Gossamer Links : Discussions :

help with if statements in link.html

Quote Reply
help with if statements in link.html
My goal is to use one set of templates and have it cover all of our bases.

What I am hoping to have link.html do is this:

If there is a detailed page, link to that.
If there is a URL link to that
If there is no URL, and no detailed, link to nothing.

I have the following code in my template link.html:
Code:
<ul><li>
<%if Full_Story%><a href="<%detailed_url%>"><%body_font%><b> <%Title%></b></font></a>
<%else%><a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%body_font%><b><%Title%></b></font></a> <%endif%>
<%if isNew%>&nbsp;<font color=red><small><sup>new</sup></small></font><%endif%>
<%if isPopular%>&nbsp;<font color=red><small><sup class="pop">popular</sup></small></font><%endif%>
<br>
<%if Description%><%body_font%><%Description%></font>
<%if Full_Story%><small> ...<a href="<%detailed_url%>">more</a></small><%endif%></font><%endif%>
</li>
</ul>

which does not account for no URL. I also want to set the field URL to be NotNull: YES to allow for not adding a url. The system will not allow this.

How can I do this? What would the exact language be? Is it as simple at an if statement? Is there a way to tell the system:

If URL=http:// then blah blah

And basically the system will ignore the default URL which is http://
Quote Reply
Re: [Evoir] help with if statements in link.html In reply to
<%if .....%>
do this
<%elsif ........ %>
do that
<%elsif ..... %>
do something else
<%else%>
whatever
<%endif%>

In order to set URL to "not null = no", you have to empty the "form regex", otherwise you may indeed not do it.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] help with if statements in link.html In reply to
Thanks Yogi!

now, a few more questions:

for the last thing, the "if there is no url" how do I say "if url=blank"? Do I say it just like that?

Also, are there any reprocussions of having url being blank? I remember something a while back that Alex said about allowing that field to be blank could cause trouble in the system. I'll do a search and see if I can find it.

Thanks. Smile
Quote Reply
Re: [Evoir] help with if statements in link.html In reply to
Hi

the easy way to mark everything else with:

<%if URL%>

something..

<%else%>

something else

<%endif%>
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [Evoir] help with if statements in link.html In reply to
<%if not URL%> (or <%unless% URL%>)
do something
<%endif%> (or <%endunless%> )

Perl considers an empty string to be "false" in boolean context.

I also have an URL field that can be empty, and I have not had any problems up to now. That doesn't mean that there aren't any, but I haven't come across them.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] help with if statements in link.html In reply to
>>
<%if not URL%>
<<

Isn't it ifnot or will both work?
Quote Reply
Re: [Paul] help with if statements in link.html In reply to
hmm, good question. I guess both will work.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Paul] help with if statements in link.html In reply to
Ok. I am a little dense. What I want is:

if there is a detailed page, to link to that
if there is a URL, to link to that
if there is not a url or a detailed page, to just show the title, not linked.

What I have so far, that does the first two, is this:

<%if Full_Story%><a href="<%detailed_url%>"><%body_font%><b><%Title%></b></font></a>
<%else%><a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%body_font%><b><%Title%></b></font></a>
<%endif%>

Can you show me using this example, how to add the <%if not URL%>?

I am not trying to be difficult. I swear.Crazy

Last edited by:

Evoir: Jul 23, 2002, 1:50 PM
Quote Reply
Re: [Evoir] help with if statements in link.html In reply to
Here you are....
Code:
<%if Full_Story%>
<a href="<%detailed_url%>"><%body_font%><b><%Title%></b></font></a>
<%elsif URL%>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%body_font%><b><%Title%></b></font></a>
<%else%>
<%body_font%><b><%Title%></b></font>
<%endif%>

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] help with if statements in link.html In reply to
Thanks. That worked like a charm!

I have another "if" question. Also in link.html:

have this odd if statement and wondered if there was a more elegant way to state this. It does seem to work the way i want it to now, but like I said, there may be a more elegant way to say it:

at the bottom of link.html I want it to be that

if there is a description, show that
if there is a description as well as a detailed page, show this "...more"

the way I have it written in the template is by nesting the "if"s:

<%if Description%><%body_font%><%Description%></font>
<%if Full_Story%><small> ...<a href="<%detailed_url%>">more</a></small><%endif%><%endif%>

It seems to do the job, but is there a better way to do this? Basically, I have some links that do not have descriptions but do have a detailed page and it seems weird to say "...more" But it is a nice touch for the links that do have a description and do have a detailed page.

Make sense?

Last edited by:

Evoir: Jul 23, 2002, 2:26 PM
Quote Reply
Re: [Evoir] help with if statements in link.html In reply to
The example you posted should work as you want it to

if there is a description => description
if there is a description and a full story => description ... more
if there is no description but a full story => [nothing]

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] help with if statements in link.html In reply to
Thanks Ivan! I really appreciate your help.