10690 Posts in 2797 Topics by 1519 members
Jump to:If this is your first visit, you will need to register before you can post. However, you can browse all messages below.
| Page: 1 | go to end | Reply | |
| Author | Topic: Little Help with if statements | 388 views |

24 June 2008 at 4:54am
Hello All!
Im trying to do something like this
<% if TotalItems - Pos = 6 %>
... do this code ...
<% end_if %>
but keep getting an error. is there a way to do PHP style if statements in a template?
as in <= , >= , % , ect.

24 June 2008 at 8:48am
What you should do is in the Page_Controller class for that page type, create a new function that does the calculation and returns a boolean to your template. Something like:
Note, I am unsure what TotalItems and Pos actually are, but I am assuming they are part of the page object if you are referencing them in the template.
So, then, in your template:
The idea is to remove such logic from your template and always handle it in your controller.
Cheers
Aaron

24 June 2008 at 9:00am
Ahh well that makes sense! Thanks for the heads up!!

24 June 2008 at 9:14am
Oh and to answer your question, no, you can't use PHP in a template. This forces you to use the MVC model the way you should.
Cheers
Aaron
| 388 views | |||
| go to top | Reply |