10394 Posts in 2203 Topics by 1714 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 985 Views |
-
Conditional logic

14 October 2010 at 10:59pm
What's wrong with this code?
<% if InSection(administrative-news) %>
administrative-news
<% else_if InSection(image-galleries) %>
image-galleries
<% else %>
... alternative content ...
<% end_if %>When the first conditional is true, this is what prints to the browser:
"administrative-news <% else_if InSection(image-galleries) %> image-galleries"When the second conditional is true, this is what prints to the browser:
"... alternative content ..."It's like the "else_if" clause is being interpreted as a string(!) What am I doing wrong?
jf/
-
Re: Conditional logic

24 June 2012 at 9:05pm Last edited: 24 June 2012 9:07pm
I believe you have to nest your if's as they don't work multi level (if, else if, else if, else) like php, only support 1 level (if, else) in templates..
ie i have done this as part of a product template and it works ok, bit of a hack but it works..
<% if Level(5) %>
<!-- 5: PRODUCT -->
<% include prod_aCatProd %>
<% else %>
<% if Level(4) %>
<!-- 4: PRODUCT LISTING.. -->
<% include prod_aCategory4 %>
<% else %>
<% if Level(3) %>
<!-- 3: STORAGE -->
<% include prod_aCategory3 %>
<% else %>
<% if Level(2) %>
<!-- 2: LANDING -->
<% end_if %>
<% end_if %>
<% end_if %>
<% end_if %>so you should have
<% if InSection(administrative-news) %>
administrative-news
<% else %>
<% if InSection(image-galleries) %>
image-galleries
<% else %>
... alternative content ...
<% end_if %>
<% end_if %>then it will check the admin news first then the image galleries and then alternative content last
hope that helps. I know this is an old post but i came across it with no answer and hopefully it helps someone..
| 985 Views | ||
|
Page:
1
|
Go to Top |


