By: Trent
Date: 2007-02-04
Time: 00:09
|
Another Conditional Display Problem
What I'm attempting to do is show a different text depending on the record count I receive from my database for a simple private messaging system I'm trying to implement. Here is the code that I have so far for my template.
<div>
[onload_menu;block=div;when [mail.new_mail]=0][lang.inbox]
</div>
<!--END NO MAIL -->
<div>
[onload_menu;block=div;when [mail.new_mail]>=1][mail.new_mail][lang.new_mail]
</div>
<!--END 1 MAIL -->
<div>
[onload_menu;block=div;when [mail.new_mail]>1][mail.new_mail][lang.new_mails]
</div>
<!--END MULTI MAIL -->
|
What I'm trying to display is the following:
First Division: If there isn't a new message, it will display "Inbox".
Second Division: If there is "1" new message, it will display "1 New Message.
Third Division: If there is more than 1 new message, it will display "X New Messages.
Now my actual sql queries and everything work fine. I can run my template with just [mail.new_mail] in it (that is my actual record count variable) and if I have 5 new messages, it will output "5". I just need to figure out how to get the switches working where I can change my text display depending on how many messages I have. I'm sure I've just missed something simple here, but I can't find it.
|
By: Trent
Date: 2007-02-04
Time: 00:53
|
Re: Another Conditional Display Problem
My updated code, but still not working.
<div>
[onload_cond1;block=div;when [mail.new_mail]=0][lang.inbox]
</div>
<!--END NO MAIL -->
<div>
[onload_cond1;block=div;when [mail.new_mail]=1][mail.new_mail][lang.new_mail]
</div>
<!--END 1 MAIL -->
<div>
[onload_cond1;block=div;when [mail.new_mail]>1][mail.new_mail][lang.new_mails]
</div>
<!--END MULTI MAIL -->
|
|
By: sheepy
Date: 2007-02-05
Time: 09:24
|
Re: Another Conditional Display Problem
The syntax for comparison is not > or >=, for compatibility with HTML, but is +- and +=- instead.
|
By: Trent
Date: 2007-02-05
Time: 22:41
|
Re: Another Conditional Display Problem
Updated code below and it's still not working? Any suggestions?
<div id="no_mail">
[onload;block=div;when [mail.new_mail]=0][lang.inbox]
</div>
<!--END NO MAIL -->
<div id="mail">
[onload;block=div;when [mail.new_mail]=1][mail.new_mail][lang.new_mail]
</div>
<!--END 1 MAIL -->
<div id="multi_mail">
[onload;block=div;when [mail.new_mail]+=-2][mail.new_mail][lang.new_mails]
</div>
<!--END MULTI MAIL -->
|
|
By: sheepy
Date: 2007-02-06
Time: 05:55
|
Re: Another Conditional Display Problem
Yes, change onload to something else. Onload is merged on template load by which time you haven't yet merged anything. Either change it to onshow or use var instead of mail
|
By: Trent
Date: 2007-02-06
Time: 16:58
|
Re: Another Conditional Display Problem
Thanks for all your help sheepy. Here is my final working code.
[onshow;if [mail.new_mail]=0;then '[lang.inbox]']
[onshow;if [mail.new_mail]=1; then '[mail.new_mail][lang.new_mail]']
[onshow;if [mail.new_mail]+=-2; then '[mail.new_mail][lang.new_mails]']
|
|
By: sheepy
Date: 2007-02-08
Time: 05:44
|
Re: Another Conditional Display Problem
My pleasure. =)
|
|
Posting in progress.
Please wait...
|