|
Cookbook /
TbsDynamicContentSummary: insert dynamic contents in your pmWiki page using TinyButStrong template engine.
Version: 2.00
Prerequisites: TinyButStrong template engine version 3.2.0 or higher
Status: in active use
Maintainer: Skrol29
Categories: Content Management System Add-Ons
Questions answered by this recipe
Or more generaly: how to insert dynamic content inside a pmWiki page ? DescriptionThis cookbook allows to insert some HTML dynamic content build from a PHP script. The PHP script must use the TBS template engine (TBS means TinyButStrong) to be functional because the cookbook takes the content directly produced by TBS. The final HTML content is actually inserted when the pmWiki page is displayed. There is no insertion using HTML iframe, nore HTML objects. This cookbook does not make learning TBS easier, it just makes easier to use TBS for pmWiki pages. If you don't know TBS here is a small description: TinyButStrong is a PHP template engine which enables you to easily build dynamic contents using Wysiwyg templates. It is one file with a PHP class having only 6 methods and 5 properties. Installation
Example of lines added in config.php:
$TbsScriptToCall['path'] = 'my_tbs_app/';
$TbsScriptToCall['customers'] = 'customers.php';
$TbsScriptToCall['regions'] = 'regions.php';
$TbsScriptToCall['products'] = 'products.php';
include('cookbook/tbs_plugin_pmwiki.php');
Since the cookbook is installed, and you have defined all alias corresponding to the PHP scripts, the content can be insterted using a markup: NoteYou can limit the placement of a content for only one pmWiki page by doing like this in the config.php file: if (pagename='Admin.Products') $TbsScriptToCall['products'] = 'products.php';
How to code a TBS script to be inserted into a pmWiki pageThis section assumes that you know the TinyButStrong template engine. They are some characteristics for the TBS script and the HTML template when you use them with the current PmWiki Cookbook: Commodities:
Restrictions:
Example of a simple script using TBS: <?php
// MySQL connection
mysql_connect('server','user','pwd');
mysql_selectdb('db01');
// The TinybutStrong class
include_once('tbs_class.php');
// Instantiate the TBS class
$TBS =& new clsTinyButStrong;
// Load the template.
// The path is relative to the current PHP script or the PmWiki root
$TBS->LoadTemplate('all_customers.html');
// Merge data
$TBS->MergeBlock('c','mysql','SELECT* FROM t_customer ORDER BY name');
// Display the result, which is redirected in the pmWiki page by the cookbook
$TBS->Show();
?>
If your script should not be run in standalone (outside a pmWiki page) then add the following line in the script: if (!defined('PmWiki')) exit();
Release NotesReleases, changelog
CommentsIn the TBS script, the creation of the TBS instance must be done by reference (using =&) when you use PHP 4.x. Otherwise, the plug-in won't work and you will have a blank content inserted in your pmWiki page. $TBS =& new clsTinyButStrong;
See AlsoContributors |