Hi,
I have the impression that an onload block is not merged if I use the TBS Joomla plugin. Maybe that is a bug (how to fix it?) or maybe I need to figure out another way of achieving what I want to do:
1.) I want to pass a parameter (offer_id) from the HTML side to the PHP side.
2.) On the PHP side, I want to verify (based on that parameter and the details of the current user) whether the current user is authorised to see this offer.
3.) If he is, I want to execute MergeBlock and show the data.
So far, I have the following HTML code:
{tbs}mergeblock=blk1;sql=SELECT what FROM offers WHERE id='54'{/tbs}
[onload;tplvars;offer_id='54';script=product_access.php;block=span][blk1.what] |
I am aware that the block is not yet conditional on the result of my script. I will implement this functionality once the rest is running.
My script "product_access.php" looks essentially like this:
$myuser = JFactory::GetUser();
$myid = $myuser->getParam('id');
$mygid = $myuser->getParam('gid');
$offer_id = $TBS->TplVars['offer_id'];
$db = JFactory::getDBO();
$db->setQuery("SELECT user_name FROM offers WHERE id='$offer_id'");
$user_id = $db->loadResult();
if (($myid == $user_id) OR ($mygid > 18)) {
$authorised = 1;
}
else {
$authorised = 0;
}
return $authorised;
|
The result is
[onload;tplvars;offer_id='54';script=/home/some12he/public_html/plugins/content/tbsplugins/product_access.php;block=span]Here follows the text from the database, which is correctly retrieved by MergeBlock. |
Any ideas?
Thanks in advance!