Categories > TinyButStrong general >

Show limited block result

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Martin
Date: 2009-12-25
Time: 13:08

Show limited block result

Hi Skrol, merry christmas. Im trying to merge the same result into a block like this:
$TBS->MergeBlock('blk_top5,blk_all',$books);
I need to show, just 5 records from blk_top5. I try this, but im
not sure ...

[blk_top5;block=begin;]
<div>[onshow;block=div;when [blk_top5.#]-=+5]
  Code here....
</div>
[blk_top5;block=end;]

[blk_all;block=begin;]
<div>
  Code here....
</div>
[blk_all;block=end;]


Or perhaps using PlugIn ByPage. Its posible do something like this:

$TBS->MergeBlock('blk_all',$books);
$TBS->PlugIn(TBS_BYPAGE, 5, 1);
$TBS->MergeBlock('blk_top5',$books);

Thanks a lot, and sorry for my poor english.
By: Iftikhar
Date: 2009-12-26
Time: 10:07

Re: Show limited block result

gdfgfg
By: Skrol29
Date: 2009-12-26
Time: 23:38

Re: Show limited block result

Hi Martin,

This is not a good way because you merge all lines for top5, and then you test each lines in order to delete the extra ones. This is an expensive method.

You'd better use a conditional section for block "blk_top5":
<div>
   [blk_top5;block=div;when [blk_top5.#]-=5]
   Code here....
<div>

But the more efficient method is to make a new PHP variable with top 5 items of $books. This can be done using the function array_slice().
$books_top5 = array_slice($books, 0, 5);
By: Martin
Date: 2009-12-27
Time: 00:06

Re: Show limited block result

Thanks Skrol, i forget to use PHP.

Im thinking all around TBS ...

Martin.