Categories > TinyButStrong general >

pmWIki plugin - multiple scripts on page

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2008-08-02
Time: 18:58

pmWIki plugin - multiple scripts on page

I am trying to have two TBS scripts on the same pmWiki page using the tbs_plugin_pmwiki.php -- but I am getting this error

Fatal error: Cannot redeclare class clsTbsLocator in C:\xampp\htdocs\pmwiki\cookbook\tbs_class.php on line 27

The php side of each of the two very similar TBS scrpts is like this
include('cookbook/tbs_class.php'); // call TBS class here

$cnx_id = mysql_connect('localhost','user','pwd') ;
mysql_select_db('db',$cnx_id) ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('reminders2.html') ;

$nbr = 8;

// Select from ALL items
$sql = "SELECT name,event_date,start_time,description,event_end,location from ltw_eventsv4 ORDER BY event_date,start_time ASC LIMIT $nbr ";

$TBS->MergeBlock('blk1',$cnx_id,$sql);
$TBS->Show() ;

* both of the scripts will run as expected when only one is called in the pmwiki page
* the error only comes when both are called like this  in the pmWiki page
-- PmWiki page code--
''Reminders: 30 days''
(:tbscontent pm_ltw_cal_reminders2:)
----
''Summary: 6 mos''
(:tbscontent pm_ltw_cal_summary2:)
----

Can anyone see what I am missing?

Thanks
TomH
By: Skrol29
Date: 2008-08-03
Time: 02:26

Re: pmWIki plugin - multiple scripts on page

Hi TomH,

instead of
include('cookbook/tbs_class.php');
you should code
include_once('cookbook/tbs_class.php');

Regards,
By: TomH
Date: 2008-08-03
Time: 02:49

Re: pmWIki plugin - multiple scripts on page

That did it, thanks (again) Skrol29

I will get a tattoo soon - on the inside of my eyelids - you know it has to say... "include_once" And every time I open or close my eyes I will see it flash before me!

Merci,
By: TomH
Date: 2008-08-03
Time: 03:00

Re: pmWIki plugin - multiple scripts on page

Ooops, I forgot the other question I had for you Skrol29..

I tried pass _GET vars lke this
(:tbscontent pm_ltw_cal_reminders2?days=32&nbr=8:)
I get the message
"(TBS for pmWiki) Error : parameter 'pm_ltw_cal_reminders?days=32&nbr=8' is not allowed."

Is there some way to pass var=val to the underlying script of the TBS for pmWiki plugin? (That would be nice ;)

Thanks,
By: Skrol29
Date: 2008-08-03
Time: 03:09

Re: pmWIki plugin - multiple scripts on page

Hi,

In the wiki tag, you can separates arguments using a space character.
Example:
(:tbscontent pm_ltw_cal_reminders2 32 8:)
In your PHP script, you can retrieve arguments using the global variable $TbsScriptArgs.

(not tested yet)
By: TomH
Date: 2008-08-03
Time: 07:20

Re: pmWIki plugin - multiple scripts on page

I'm testing this ;) and not seeing any results... except error
"TinyButStrong Error in field [var.parms...] : the PHP global variable named 'parms' does not exist or is not set yet. This message can be cancelled using parameter 'noerr'."

This is being tested as follows... adding the following to the existing TBS page that is now working in PmWiki

php

... php code that works correctly ...

...and adding each of the following to test, one at a time...

$nbr = 8;
$days = 32;
// and testing each of the following individually, (one at a time)
// $parms = print_r($TbsScriptArgs,true);
// $parms = print_r($GLOBALS['TbsScriptArgs'],true);
// $parms = print_r($TBS,true);

//$arr = array("key1"=>"val1","key2"=>"val2");
//$parms = print_r($arr,true);

// $parms = print_r($GLOBALS['ArgLst'],true);
// $parms = print_r($GLOBALS['PrmLst'],true);
// $parms = print_r($GLOBALS['_TbsContentForPmWiki'],true);

$TBS->Show();

html
nbr = [var.nbr] ( no result )
<br />
days = [var.days] ( no result )
<br />
parms = [var.parms] ( no result )

...TBS block code that works...


None of the various $parms defined produce any output at all.
Also no result for simple var.val as shown above

What am I missing here?

Thanks a lot for your endless patience,
TomH
By: TomH
Date: 2008-08-03
Time: 07:42

Re: pmWIki plugin - multiple scripts on page

Hello again,

I just realized I could not get the results to show because they were NOT GLOBAL in the pmWiki context.

When you described $TbsScriptArgs as global I was mislead by that, sorry for that.