PHP, Smarty or TinyButStrong ? Read the article Doing PHP templates of the third kind.
This is a FAQ for those who don't use TinyButStrong yet.
Another FAQ for users is available at the Support page.
TinyButStrong is engineered like a tool for reporting and specialized for Web interfaces. This concept enables you to create small and big projects faster and with more simplicity. Here are the three particular advantages of TinyButStrong:
For most Template Engines, there are some kind of code for loops and variables in the template itself. For example, to multiply the rows of a table with another template engine, you may have:
Html side (without TinyButStrong)
{section name=sec1 loop=$nbr} <tr>...</tr> {/section}
Php side
$Obj->Do('sec1');
With TinyButStrong , there is no piece of code in your Templates. Code is all
in the Php side. If you need to multiply the rows of a table,
use a block which you combine with a data source using only one Php statement.
Example :
Html side (with TinyButStrong)
<tr>...[sec1;block=tr]...</tr>
Php side
$TBS->MergeBlock('sec1',$nbr);
TinyButStrong supports a large range of data sources. You can manage data display exceptions using conditional displays and event Php functions. But all the way, programming and designing are always perfectly separated. TinyButStrong has features for classical problems such as alternated colors, multi-column display and header groups.
TinyButStrong is the only Template Engine which has viewable tags for all visual (WYSIWYG) Html editors. This is possible when using tags with relative locations. Their syntax is also more simple and more clear. Here's an example that shows how to define a block bound to a row of a table:
Without TinyButStrong
<table> {section name=sec1} <tr> <td>hello</td> </tr> {/section } </table>
With TinyButStrong
<table> <tr> <td>hello[sec1;block=tr]</td> </tr> </table>
In visual mode
[sec1;block=tr] |
If the TinyButStrong's relative syntax does not appeal to you, there is also a traditional absolute syntax.
Displaying information from your database, that's one of the most frequent operations in a Web application. Only one Php statement is needed to make data reading loops, and display that data in the Template. TinyButStrong supports in native MySQL, PostgreSQL, SQLite, and Php arrays. If you use other databases, TinyButStrong can adapt to them using database plug-ins that you add to your program.
Tiny
Because there is only one file to install. It's made of only one class with 6 methods and 5 properties. In order to compare, the Smarty engine is made of several files, the main class of it has 38 methods and 34 properties.
Strong
It doesn't stop at usual engines' features. It offers more: event functions, numeric and date format, multi-column, display, database reading...
TinyButStrong is completely free. It is published under the LGPL license. This is the most used license for free softwares. It enables you to include TinyButStrong in your projects, even commercial, and to modify the code in order to fix it or to make it work with your other programs for example. Nevertheless, you can not appropriate TinyButStrong. For a commercial use, you must respect the LGPL license by telling the changes and not adding license on the TinyButStrong module, even modified.
TinyButStrong knows how to read sequentially data coming from several types of database. Thank to it, TinyButStrong can merge data very simply with only one instruction.
Example: $TBS->MergeBlock('block1',$conn,'SELECT
* FROM clients ORDER BY cli_id');
This instruction enables you to merge the block named 'block1' with
the result of the SQL : 'SELECT
* FROM clients ORDER BY cli_id'
, applied to connection $conn
.
The MergeBlock()
method will open the query on its own, and read records sequentially
in order to merge them one by one with the block.
TinyButStrong does nothing more than reading data sequentially, and it needs that the connection is already opened on the database. So it's very simple and secure. You can even make it to read data from specific databases by programming your own reading functions. Thus, TinyButStrong does not replace unified connectivity tools such as EzSQL or jlADOdb. But it can be connected to these tools to make the merge.
All database types can be supported by the merge function of TinyButStrong. Some databases are recognized in native, the others can be recognized using a database plug-in. Database recognized in native are: PDO, MySQL, SQLite, PostgreSQL and PHP Array.
Some Template Engines are able to make a stand-alone Php version from a Template. That's what is called a 'compiled template'. Unfortunately, TinyButStrong is not able to make compiled templates for the moment.
Other Template Engines propose the delimitors {} for their special tags. With TinyButStrong, default delimitors are []. Of course you can change them without changing the source code. But why this peculiarity? The characters { and } are used a lot in Html pages for JavaScript coding and CSS styles' definitions. While [ and ] are used very seldom. By choosing [], you're speeding up the process because special tags are localized more fast.