Categories > TinyButStrong general >

Queries regarding to the TBS

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: pani
Date: 2012-07-02
Time: 06:37

Queries regarding to the TBS

Dear Sir,

Presently I am using TBS 3.8 version. Here is the some queries regarding to the TBS.

•    When I am using a block once and how can I reuse same block with in the same page ie., how can I reuse block once defined?

•    Is there is any Ignore block in TBS?

•    In examples folder, tbs_plugin_bypage.php, is there any sorting mechanism when I use paging system within the page? How can I achieve this type of functionality?


If you are free, feel free to suggest to rectify the issues.

kinds regards,
pani.
By: Skrol29
Date: 2012-07-02
Time: 18:29

Re: Queries regarding to the TBS

Hello Pani,

> When I am using a block once and how can I reuse same block with in the same page ie., how can I reuse block once defined?

May be you can use GetBlockSource().
http://www.tinybutstrong.com/manual.php#php_getblocksource

> Is there is any Ignore block in TBS?

What to you mean by "ignore" ?
You can delete a block using MergeBlock('my_block', 'clear').

> In examples folder, tbs_plugin_bypage.php, is there any sorting mechanism when I
> use paging system within the page? How can I achieve this type of functionality?

Sorting data can be done over the ByPage feature if your data source is SQL.
You just have to build your storing clause for the SQL statement and give the final SQL statement to MergeBlock().
By: pani
Date: 2012-07-11
Time: 07:29

Re: Queries regarding to the TBS

Dear Sir,

Suppose that in our form there exists the following address
1. Postal Address
2. Residential Address
3. Kin Address
4. Employer Address
5. Other Address

Each and every address there exists country field which is dropdown box, end user select their country.

Once i am define in the Postal Address country fields, in the same block how can i reuse Residential Address, Kin Address, Employer Address etc ... without repeating the code. That is my goal.


In case of Ignore block I am not explaining clearly to you. My ambition is certain condition it shows that block and certain conditions it does not show.

Thank you for your valuable guidelines.

Thanking you & regards,
Pani.
By: kle_py
Date: 2012-07-11
Time: 14:12

Re: Queries regarding to the TBS

Maybe the manual section:
"Merging several blocks with the same data:"
can help You in this point

Example: $TBS->MergeBlock('block1,block2,block3','mysql','SELECT * FROM MyTable');
block1, block2 etc might be the different country lists showing the same information on the same web form.

.. Happy coding :)
By: Skrol29
Date: 2012-07-11
Time: 21:25

Re: Queries regarding to the TBS

The solution of Kle_py is to merge sevral blocks with the same data. It is good for populating several time to country list.

But if you need to duplicate a part of the template before to merge it, here is an example closed to your template :

In this example, the country selection is not done. It can be done using Javascript, or using the Html plug-in for TBS.
The code first merges the country in order to feed the list which will be common to all addresses.
Then it merges all adress types.
At the end it merges your data in the text zones.

HTML :
<div>
  [adr.val;block=div] Adress:
  Line1:   <input type="text" name="[dat.[adr.key]_line1]" value="" />
  Line 2:  <input type="text" name="[dat.[adr.key]_line2]" value=""  />
  Coutry: <select name="[dat.[adr.key]_country]">
     <option value=[country.key]>[country.val;block=option]</option>
  <option>
</div>

PHP:
$TBS->MergeBlock('country', $data_country);

$adr_types = array(
  'p' => "Postal",
  'r' => "Residential",
  'k' => "Kin",
  'e' => "Employer",
  'o' => "Other",
);
$TBS->MergeBlock('adr', $adr_types);

$TBS->MergeBlock('dat', $your_data);