Gossamer Forum
Quote Reply
Syntax Problems
I am trying to make a make it so that I can display banners based on the category name. It works fine except for the ones that have the word "and" in them. Here is an example of the code. Code in green will call fine, code in red will default to the <%else%> statement:

Code:
<%if $title eq 'Category'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation.com">
<%elseif $title eq 'Category: One and Two'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation1.com">
<%elseif $title eq 'Category: Three'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation2.com">
<%if $title eq 'Category Two and Three'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation3.com">
<%if $title eq 'Category Four'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation4.com">
<%elseif $title eq 'Category Four: One'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation5.com">
<%elseif $title eq 'Category Four: Two and Three'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation6.com">
<%if $title eq 'Category Five'%>
<a href="
http://www.htmllinktobanner.com"><img src="http://www.bannerlocation7.com">
<%else%>
<%title%>
<%endif%>


How can I make this call the code if they have the word "and" in them instead of reverting to the <%else%> statement. I am entering in the ' ' exactly as it displays when called from <%title%>, so I don't know of any other way to do this. Somebody PLEASE help me! I am going nuts with this!!!
Quote Reply
Re: [eclipse] Syntax Problems In reply to
If this is too confusing, I guess the simpler way to put it is, how can I make it not think of the "and" word as syntax, but instead as part of a phrase. It seems to be ignoring the ' that I put around the phrase. I have also tried using " with no luck. Also \'\ and \"\ without luck either.

Code:
<%if $title eq '1 and 2'%>


I can understand what it is trying to do. It is trying to say that $title=1 and $title=2 must be true inorder to display what I want. But of course this can never be true, so it will resort to whatever is in the <%else%> statement. There must be a way to do this! It is driving me nuts!!!
Quote Reply
Re: [eclipse] Syntax Problems In reply to
This seems to be caused by the fact that the parser expects and's to be used in conditions and when it finds an "and" it splits on it...

Code:
elsif ($tag =~ /\sand\s*(?:not)?\s/i) {
@tests = grep $_, split /\s+and\s*(not)?\s+/i, $tag;
$bool = ' and ';
}

..so it's screwing up your condition.

Without a hacking of that regex it's going to be hard to get around (unless I missed something).

Last edited by:

Paul: Apr 13, 2003, 2:32 PM
Quote Reply
Re: [Paul] Syntax Problems In reply to
Yep... that's the exact problem I am having! I think I have figured something out. I tried changing the "and" to "&" and that seems to work OK, so I am just renaming my categories as a work around.

Last edited by:

eclipse: Apr 13, 2003, 2:35 PM