Categories > TinyButStrong general >

onload with Joomla plugin

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: wobe
Date: 2009-05-02
Time: 16:34

onload with Joomla plugin

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!
By: Skrol29
Date: 2009-05-04
Time: 12:47

Re: onload with Joomla plugin

Hi Wobe,

Yes, it's a kind of bug. Though there may have a security problem when it is automatically activated.

You can force the [onload] blocks to be merged in your own script using:
$TBS->LoadTemplate(null,'');

I will fix the plug-in.