Categories > TinyButStrong general >

Display depending on condition...

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Capis
Date: 2006-01-19
Time: 05:56

Display depending on condition...

Hi! Im making a personal site to post some notes and I have this trouble.
IE: I have a table with this data:

id|note|viewed
1|blabla|0
2|jijiji|0
3|coco|1
4|rerere|0

and I want to display the records with different format depending on the field "viewed". I cant figure out how to do it, can you help me with this?

Thanks!
By: Skrol29
Date: 2006-01-19
Time: 13:09

Re: Display depending on condition...

Hello Capis,

I suggest you to use conditional sections.
It work like this:
<tr><td>[blk.id;block=tr;when [blk.viewed]=1]</td>...Format1...</tr>
<tr><td>[blk.id;block=tr;default]</td>...Format2...</tr>
By: Capis
Date: 2006-01-19
Time: 14:31

Re: Display depending on condition...

Thanks a lot Skrol29!!
By: Capis
Date: 2006-01-19
Time: 18:30

Re: Display depending on condition...

Hi, im bothering you again...
I have this code, its related with my previous question

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
  <td width="4%" align="center"><input type="checkbox" name="[block1.id;block=tr]" value="ON"></td>
  <td width="46%"><a href="[block1.id;block=tr]">[block1.asunto;block=tr]</a></td>
  <td width="21%"><span class="comentarioblack">[[block1.rte;block=tr;when [block1.leido]=1]]</span></td>
  <td width="29%"><span class="comentarioblack">[[block1.fecha;block=tr]]</span></td>
</tr>
<tr>
  <td width="4%" align="center"><input type="checkbox" name="[block1.id;block=tr]" value="ON"></td>
  <td width="46%"><a href="[block1.id;block=tr]">[block1.asunto;block=tr]</a></td>
  <td width="21%"><span class="comentario3">[[block1.rte;block=tr;default]]</span></td>
  <td width="29%"><span class="comentario3">[[block1.fecha;block=tr]]</span></td>
</tr>
</table>

It doesnt show the rows according to the field "leido", it just show the rows alternating first ant second <tr></tr> contents... Im really sure I did something wrong, but I cant figure out what.

Thanks!
By: Skrol29
Date: 2006-01-19
Time: 19:02

Re: Display depending on condition...

Hi Capis,

You shouldn't repeat "block=tr" for each fields of a same section. Only one is needed and only the first one is taken in acount. On each section you have in your snippet, there is no "when" or "default". That's why it's like they are not there.

Your snippet should be:
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
  <td width="4%" align="center"><input type="checkbox" name="[block1.id]" value="ON"></td>
  <td width="46%"><a href="[block1.id]">[block1.asunto;block=tr;when [block1.leido]=1]]</a></td>
  <td width="21%"><span class="comentarioblack">[block1.rte]</span></td>
  <td width="29%"><span class="comentarioblack">[block1.fecha]</span></td>
</tr>
<tr>
  <td width="4%" align="center"><input type="checkbox" name="[block1.id]" value="ON"></td>
  <td width="46%"><a href="[block1.id]">[block1.asunto;block=tr;default]</a></td>
  <td width="21%"><span class="comentario3">[block1.rte]</span></td>
  <td width="29%"><span class="comentario3">[block1.fecha]</span></td>
</tr>
</table>

By: Capis
Date: 2006-01-19
Time: 19:07

Re: Display depending on condition...

Thanks a lot! (again)