Here is the source code and the install procedure for a very basic Joomla application that works with the TBS plug-in.
This application present a search area, and the result of the search trough a table in the Joomla database.
Installation:
-------------
1) create a folder "applications/simple_search" under the Joomla folder.
2) put the following files
3) create a new Joomla article with the following contents: {tbs}script=applications/simple_search/index.php{/tbs}
4) in the TBS plug-in parameters (under Joomla plug-ins), add the article id to the hallowed ids.
Files:
------
index.php
<?php
/* Simple Search application
Skrol29, 2012-03-01
*/
if (!isset($TBS)) exit("This application can work only under Joomla.");
// Retrieve user parameters
global $what;
$what = isset($_POST['what']) ? $_POST['what'] : ''; // text to search
// Load the template
$TBS->JoomlaArticle->title = 'Simple Search';
$TBS->LoadTemplate(dirname(__FILE__).'/tpl_main.html');
if ($what=='') {
// nothing to search
$TBS->MergeBlock('c', 'clear');
} else {
$sql = "
SELECT id, name
FROM jos_components
WHERE (name LIKE '%".str_replace("'", "''", $what)."%')
ORDER BY id
";
$TBS->MergeBlock('c', 'mysql', $sql);
}
/* END : do not use exit() nore TBS->Show() in order to let Joomla continue the process
*/
return; // go back to Joomla
|
tpl_main.html
<form action="" method="post">
Search for:
<input type="text" name="what" value="[onshow.what]"/>
<input type="submit" name="btn_ok" value="OK" />
</form>
<p>Result:</p>
<table border="1" cellspacing="0" cellpadding="4">
<tr>
<th bgcolor="#999999">Id</th>
<th bgcolor="#999999">Name</th>
</tr>
<tr>
<td>[c.id;block=tr]</td>
<td>[c.name]</td>
</tr>
<tr class="nodata">
<td colspan="2">[c;block=tr;nodata]No item found</td>
</tr>
</table>
|