Gossamer Forum
Home : Products : Gossamer Links : Discussions :

If, Else and Endif

Quote Reply
If, Else and Endif
Hi...

Please could someone have a quick look at these "if" statements and let me know what I am doing wrong.

what is happening is that if Type = Link the Add_Date field still shows up if it has a value.

Example:

<%if Type = 'Article'%>
<p><%if Add_Date%><i>Published: <%Add_Date%></i><br><%endif%>
</p>
<%endif%>

Example 2:

And here, Type is set to "Link" but the "ArticleDescription" is showing and not the "Description"

<%if Type = 'Article'%>
<%if ArticleDescription%><div class="description"><%ArticleDescription%></div><%else%>
<%if Description%><p class="description"><%Description%></p><%endif%>
<%endif%>

Many Thanks!
Quote Reply
Re: [aquaman] If, Else and Endif In reply to
Hi,

You need to use this kind of formatting;

Number;

<%if field > 5%>
<%if field >= 5%>
<%if field <= 5%>
<%if field == 5%>
..etc

For normal text/char fields;

<%if field eq "something"%>
<%if field contains "something"%>
<%if field ne "something"%>
..etc

To answer your question though, this should work;


Code:
<%if Type = 'Article'%>
<p>
<%if Add_Date%><i>Published: <%Add_Date%></i><br /> <%endif%>
</p>
<%endif%>

<%if Type eq 'Article'%>
<%if ArticleDescription%>
<div class="description"><%ArticleDescription%></div>
<%elsif Description%>
<p class="description"><%Description%></p>
<%endif%>
<%endif%>

Hope that helps :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] If, Else and Endif In reply to
Thanks Andy,

I am not sure why this is happening but I have the Type set to 'Link' and it still shows the fields if they have values.

E.g. Published: <%Add_Date%> still gets output to the page

Any suggestions?

Many Thanks
Quote Reply
Re: [aquaman] If, Else and Endif In reply to
FIXED!! I found out what I was doing wrong

I was testing with this

<%if Type = 'Article'%>
Type is <%Type%>
<%else%>
Its working
<%endif%>

and changed the "=" to "eq" so its now

<%if Type eq 'Article'%>
Type is <%Type%>
<%else%>
Its working
<%endif%>

Last edited by:

aquaman: Jul 29, 2005, 11:07 AM
Quote Reply
Re: [aquaman] If, Else and Endif In reply to
Ah, whoops.

I did have it as <%if Type eq 'Article'%> on the second condition .. but I guess I didn't update the other one for you Crazy

Glad its working though :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!