Categories > TinyButStrong general >

conditional subblock problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mgb
Date: 2007-10-01
Time: 14:02

conditional subblock problem

I only want banners of the first 10 on my toplist
<table class="toplist">
  <tr>
    <th>number</th>
    <th>name</th>
    <th>hits in</th>
    <th>hits out</th>
  </tr>
[toplist;block=begin]
  <tr>
    <td>[toplist.#;noerr]</td>
    <td><a href="/toplists/out/?id=[toplist.id;noerr;ifempty=0]">[toplist.name;noerr]</a></td>
    <td>[toplist.hitsin;noerr;ifempty=0]</td>
    <td>[toplist.hitsout;noerr;ifempty=0]</td>
  </tr>
  <tr>
    <td colspan="4">
      <a href="/toplists/out/?id=[toplist.id;noerr;ifempty=0]">
        <img src="[toplist.bannerurl][when [toplist.#] -+ 11;magnet=tr]" border="0" />
      </a>
    </td>
  </tr>
  <tr>
    <td colspan="4" class="desc">[toplist.description;noerr]</td>
  </tr>
[toplist;block=end]
</table>
What am I missing?
By: mgb
Date: 2007-10-01
Time: 14:27

Re: conditional subblock problem

I replaced
<img src="[toplist.bannerurl][when [toplist.#] -+ 11;magnet=tr]" border="0" />
with
<img src="[toplist.bannerurl][onshow;when [toplist.#] -+ 11;block=tr;magnet=tr]" border="0" />
and it worked.
but is there a way where I dont use the onshow?
where it all happens as I merge toplist?
By: Skrol29
Date: 2007-10-03
Time: 00:34

Re: conditional subblock problem

Hi Mgb,

I think it is not good the make the limitation at the HTML side. You should make your SQL query to return only 10 records.

MySQL : SELECT * FROM table1 ORDER id LIMIT 10

By: mgb
Date: 2007-10-03
Time: 10:16

Re: conditional subblock problem

Oh sorry, I might have given you the wrong idea.
My toplist is 50 entries long I select it out with a limit 50.
I select out bannerurl for all 50, but on my side I only want the banner to be show for the first 10.
the 40 rest should only have text shown.
Sorry
By: Skrol29
Date: 2007-10-03
Time: 13:35

Re: conditional subblock problem

ok, so a better solution is to use conditional section of blocks.

<table class="toplist">

  <tr>
    <th>number</th>
    <th>name</th>
    <th>hits in</th>
    <th>hits out</th>
  </tr>

  <tr>
    <td>[toplist.#;block=tr;noerr]</td>
    <td><a href="/toplists/out/?id=[toplist.id;noerr;ifempty=0]">[toplist.name;noerr]</a></td>
    <td>[toplist.hitsin;noerr;ifempty=0]</td>
    <td>[toplist.hitsout;noerr;ifempty=0]</td>
  </tr>

  <tr>
    <td colspan="4">
      <a href="/toplists/out/?id=[toplist.id;noerr;ifempty=0]">
        <img src="[toplist.bannerurl;block=tr;when [toplist.#] -+ 11]" border="0" />
      </a>
    </td>
  </tr>

</table>

The first <TR> titles, the second <TR> is a normal section of block, it will be displayed for each records. The third <TR> is a conditional section of block (with both parameters block and when), it is displayed for all records that have the condition verified.
By: Skrol29
Date: 2007-10-03
Time: 13:38

Re: conditional subblock problem

PS:

My last solution won't work anymore if you add your last <TR> with description.
If you want it it, you have to change the last <TR> with :
  <tr>
    <td colspan="4">
      <a href="/toplists/out/?id=[toplist.id;noerr;ifempty=0]">
        <img src="[toplist.bannerurl;block=tr;when [toplist.#] -+ 11]" border="0" />
      </a>
    </td>
  </tr>
   
  <tr>
    <td colspan="4">
      <a href="/toplists/out/?id=[toplist.id;noerr;ifempty=0]">
        <img src="[toplist.bannerurl;block=tr+tr;when [toplist.#] -+ 11]" border="0" />
      </a>
    </td>
  </tr>
  <tr>
    <td colspan="4" class="desc">[toplist.description;noerr]</td>
  </tr>

  <tr>
    <td colspan="4" class="desc">[toplist.description;noerr;block=tr;default]</td>
  </tr>
By: mgb
Date: 2007-10-03
Time: 13:50

Re: conditional subblock problem

thanks Skrol29
I think I fixed it with
  <tr>
    <td colspan="4" class="desc">[toplist.description;noerr;block=tr;when [toplist.#] +- 10]</td>
  </tr>
now the first 10 wont have a description, but a banner :)
Thanks again, I really like working with tbs it somehow has a more intuitive way of mixing php and html. thanks!