Gossamer Forum
Home : Products : Links 2.0 : Customization :

"or" operator in templates

Quote Reply
"or" operator in templates
I was just wondering if there is a way to use the "or" operator in templates. Or if there is something like it that I can used? I have a part of a <table> that I only want to show if several fields are populated in the database.

So something like this
<%if islinked or isdetailed or ispopular%>

Thanks.

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: "or" operator in templates In reply to
Firstly, if all the fields are required, the operator is "and", not "or".

There is no "and" or "or" operator in the template parser.

Solution 1.

You can use nested <%if%> tags.

Solution 2.

You can hardcode a new tag within the script (site_html_link and site_html_detailed).

Add this:
Code:
($rec{field1} and $rec{field2} and $rec{field3}) and ($show_html = 1;);
And this:
Code:
show => $show_html
Happy Coding,

--Drew
http://www.FindingHim.com
Quote Reply
Re: "or" operator in templates In reply to
If 'any' of the fields are populated I want to draw the <table> so wouldn't that be a "or"?

Thanks.

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: "or" operator in templates In reply to
That's not how I interpreted your original statemnet "if several of the fields are populated...".

Use the code as provided before, except replace "and" with "or".

Then in your templates, use:
Code:
<%if show%>
You code here.
<%endif%>
Happy Coding,

--Drew
http://www.FindingHim.com
Quote Reply
Re: "or" operator in templates In reply to
you could try entering the 'or' commands in the 'Template.pm'
You'd have to be using the enhanced version of Template.pm

-Taylor
http://mainstop.con/mods/links2


Quote Reply
Re: "or" operator in templates In reply to
Sorry... should have been more descriptive. Junko, the code that you gave works okay when I put "or" in instead of and.

Thanks.

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net