Categories > TinyButStrong general >

Using TBS in Joomla to fire a dynamic query...

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: paula
Date: 2009-03-22
Time: 14:07

Using TBS in Joomla to fire a dynamic query...

Hello,
I have been successfully able to install tbs plugin in joomla and am also able to run the example given in help file: {tbs}mergeblock=u;sql=SELECT name, email FROM jos_users ORDER BY name{/tbs}

From past several hours I have been trying to make this query dynamic based on a request parameter but I am unable to do so. In fact, I am not even able to access request parameters. I have tried several ways without success, such as -

{tbs}embedded{/tbs}
<!--TBS 
$TBS->MergeBlock('u','array',$_GET); 
-->
<table border="0"><tbody><tr><td>[u[Itemid];block=tr]</td></tr></tbody></table>


Can someone please tell me what am I doing wrong?

thank you!
By: paula
Date: 2009-03-23
Time: 03:22

Re: Using TBS in Joomla to fire a dynamic query...

As a test, I tried to repeat the code that prints a table.
{tbs}mergeblock=u;sql=SELECT id, name, email FROM jos_users ORDER BY name{/tbs} <table border="0"><tbody><tr><td>Name</td><td>Email</td><td>ID</td></tr><tr><td>[u.name;block=tr]</td><td>[u.email]</td><td>[u.id] </td><td> </td></tr></tbody></table>

The above works well. The following is a copy of the above but doesn't print anything. I also tried changing the mergeblock variable from u to k.

{tbs}mergeblock=u;sql=SELECT id, name, email FROM jos_users ORDER BY name{/tbs} <table border="0"><tbody><tr><td>Name</td><td>Email</td><td>ID</td></tr><tr><td>[u.name;block=tr]</td><td>[u.email]</td><td>[u.id] </td><td> </td></tr></tbody></table>
By: paula
Date: 2009-03-23
Time: 04:36

Re: Using TBS in Joomla to fire a dynamic query...

ok, so I finally got the following snippets to work -

1. Simple query with no parameter
{tbs}mergeblock=k;sql=SELECT id, name, email FROM jos_users ORDER BY name{/tbs} <table border="0"><tbody><tr><td>Name</td><td>Email</td><td>ID</td></tr><tr><td>[k.name;block=tr]</td><td>[k.email]</td><td>[k.id] </td><td> </td></tr></tbody></table><br />


2. Simple query with hardcoded parameter - {tbs}mergeblock=u;sql=SELECT id, name, email FROM jos_users where id=65{/tbs}
<table border="0"><tbody><tr><td>Name</td><td>Email</td><td>ID</td></tr><tr><td>[u.name;block=tr]</td><td>[u.email]</td><td>[u.id] </td><td> </td></tr></tbody></table>


3. Embedded php code containing a query with a request parameter -

{tbs}embedded{/tbs}
<!--TBS  
$key =  intval($_GET['bankid']);      
$TBS->MergeBlock('m','mysql','SELECT name FROM jos_users WHERE id='.$key); 
-->
<table border="0"><tbody><tr><td>[m.name;block=tr]</td></tr></tbody></table>

The following things didn't work -
1. The merge block names (i.e. the u, k, and m) must be different. Multiple blocks with same name don't work. This could probably be mentioned in the help doc.
2. This loc from the help doc didn't work -
$key = (isset($_GET['bankid']) ? intval($_GET['bankid']) : 0;

It is throwing the following error -
Parse error: syntax error, unexpected ';' in /home/.../content/tinybutstrong.php(173) : eval()'d code on line 1

Any idea why?

Also, I am still not able to figure out how to print all the request parameters in the ooutput page. Please help.