Categories > TinyButStrong general >

getting started

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Kevin
Date: 2010-03-23
Time: 15:36

getting started

the manual says
[quote]
Copy the file tbs_class.php  in a directory of your Web site.
2.     At the beginning of your PHP program, add the lines:
  include_once('tbs_class.php');
  $TBS =& new clsTinyButStrong ;
Remark: if the TBS file tbs_class.php is in a different directory than your application, then you have to precise the directory in front of the TBS file name.
[/quote]

What is the PHP program? I am having a hard time figuring this thing out.
By: Skrol29
Date: 2010-03-23
Time: 16:15

Re: getting started

Hi Kevin,

It is the PHP script your are coding.
What would be a clearer expression for you?
By: Kevin
Date: 2010-03-23
Time: 16:42

Re: getting started

No, how do I connect and show my data?

Example; I have a table named florists.
Fields named: name, phone, hours.

How do I show all of the florists with their respective information?
By: Skrol29
Date: 2010-03-23
Time: 16:51

Re: getting started


They are online snippets that answer very well to your question.
They are in the section "Examples".
By: Kevin
Date: 2010-03-23
Time: 17:58

Re: getting started

I have looked at those, but which example would apply to what I am doing. I think I will be okay once I can relate an example to one of my scenarios.
By: TomH
Date: 2010-03-23
Time: 21:11

Re: getting started

The beginning, trying to get your arms around the basics, is the hardest -- especially if you are not fully familiar with PHP and database connections jumping the next step to also using PHP & database with TBS -- but we've all done it anbd so can you.

1) go here... http://www.tinybutstrong.com/examples.php

2) choose the "Data" example

3) leave it set at "Array" the TBS part is the same whether it's using a PHP array as the source of the data or a database query for the source of the data

4) examine how the results look in the right hand side of the page

5) at the top of the left column, in the "Display" area, select the "PHP program" button

6) look at the PHP code shown there, you'll see the array()'s  defined that hold the source data (a temporary substitute for a database look up)

7) mentally walk thru the half dozen lines that start "$TBS->"

7a) the first starts up the TBS template class for this script
7b) next one tells TBS which template (HTML) file to load and use for filling in the various blocks of data
7c) next the $TBS->MergeBlock('blk1',$array_type1) line tells TBS to go to the template and look for elements that have the block named 'blk1' then use the data source '$array_type1' to fill that block with data from that array

8) at the top of the left column, in the "Display" area, select the "HTML Template" button and look (on the right side) for the place where there's HTML coding for 'blk1'

9) now TBS knows that you are intending to repeat the values from the array ($array_type1) in this area of the page that has been identified as 'blk1' (an arbitrary name that just tells TBS which part of the page you want to stuff the data into

10) the term 'blk1.key' is the way that TBS identifies the parts of the data that you are filling into the table from the $array_type1 data source -- like saying take the 'key' from the first element of the array and put it here and 'blk1.value' means put the value from the first element there

11) TBS knows that you intend to repaet this procedure for every element in the array - so it does that untill it runs out of elements in the array - then it move on to the next block ( 'blk2' )

12) now look at the second part 'blk2' and follow the bouncing ball for that part of the example.

----

If this is confusing... then go to the very first of the examples, the "Hello World" example and work your way through that, then the next, and the next, etc.

The examples page is the most productive way to gradually build up your understanding of how TBS interacts with PHP, the sources of data, and the HTML template.

Hope that helps,