Categories > TinyButStrong general >

Subblock problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: François
Date: 2006-01-26
Time: 11:13

Subblock problem

Here is my problem:

I'm working on a search engine, and I have to display two kinds of results:

-products
-other results
OR
-a mixed of the two

Whatever kind of results I want to display (product, others, or mix), I have the same structure:

-title with number of results
-navigation bar
-results

As the three kind of results share the same layout, I thought I could use a subtemplate to avoid repeating three times the same code in my template.
But I can't do this for the moment. I'm not using database queries, so subqueries are not a solution. Plus I have to analyze a bit the results to decide how to display my results.

I was using another template system before, and I was able to do this:
merge the results+nav bar from an array, then merge a first time the "results block" (title+nav+results).
Then merge once again the results+nav bar from a second array, then merge a second time the SAME "results block".

WIth TBS, I understand that once you merge a block, its not usable anymore. So I thought about merging my "results block" from an array with my two arrays of results, but first I don't know how to do it, and second, I don't see how I could add my code to slightly change the display according to the type of results and the results themselves.

I know it may not be very clear -sorry about my english-, but I hope someone can tell me if what I want is really impossible with just one result block for the three kinds of results. I don't mind repeating my main block three times, it will work. But I would like to simplify.
By: Tom
Date: 2006-01-26
Time: 15:23

Re: Subblock problem

Seeing that everyone else is sleeping in today you'll get one newbie helping another ;-0

From a recent post - there's a method for writing the results of a Merge to a string (using the RENDER trick)
http://www.tinybutstrong.com/forum.php?msg_id=4357

ANd another post to use the content from those string(s)
http://www.tinybutstrong.com/forum.php?msg_id=4189

Doing multiples should be as easy as
$TBS->Source = $my_template_source_part1;
$TBS->Source .= $my_template_source_part2;
$TBS->MergeSpecial('onload');

Read the posts to get the nitty gritty

HTH
By: Skrol29
Date: 2006-01-27
Time: 19:54

Re: Subblock problem

Hello François,

I'm not sure to well understand your problem. But If you'd like to use one structure of a block in a template to merge this block 3 times and then place those tree merged block inside the main template, then I can suggest someting.

A first issue is to use the method GetBlockSource(). You can then get the source of a block, eventually retouch it by changing block's name, and then put it somewhere else in the template using MergeField(), or MergBlock() with keyword "text".

Another way is to copy your block tree times in the template in design mode, with diffrent names. Then, when merging, delete unused block with MergeBlock() with keyword "clear".

I hope this helps.