Categories > TinyButStrong general >

OOP Question... and Problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: OverNode
Date: 2007-02-22
Time: 14:29

OOP Question... and Problem

Hello,
I have TBS 3.2, PHP 5.2.1, apache 2.2.4 ans MySQL 5.0.27
I'm using TBS and TBSsql.
I have a class named Data that processes the data that is then used by TBS.
In my index.php file I have:

        $p=new Data();
   
    $TPL=new clsTinyButStrong();
    $TPL->LoadTemplate($p->page_tpl);
    $p->TplUpdatePaths($TPL->Source);
    $TPL->ObjectRef['p'] =& $p;
    $TPL->Show();
The loading is ok, the TPLUpdatePaths is ok too but there is a problem  for ObjectRef.
My HTML file calls a $p var named $tpl_dir;
Here is an extractof of data.class.php:

class Data
{
   
    public $HEAD; //head html(meta data, script, style, title, doctype etc. etc.)
    public $MAIN;    //main page html
    // sub html data
        public $SCRIPT; //javascript scripts
        public $STYLE; //css style includes
        public $METADATA; //metadata
        public $TITLE; //title of the page
       
   
    public $tpl_dir; //template dir
    public $tpl_data; //all data loaded from template
    public $page ;    //page name
    public $page_data; //all the page data that is in DB
    public $pageID;    //page ID for fast access if needed
    public $page_tpl; //template for the COMPLETE page
My constructor function defines all the variables correclty.
Finally, in my HTML file I have:
[onload;script='tpl/[var.~p.tpl_dir]/positions/top.php';subtpl]

My problem is that when the page is show, I get this message:
TinyButStrong Error in field [var.~p.tpl_dir...] : property ObjectRef is neither an object nor an array. Its type is 'boolean'. This message can be cancelled using parameter 'noerr'.
and
TinyButStrong Error in field [onload...] : the file 'tpl/[var.~p.tpl_dir]/positions/top.php' given by parameter script is not found or not readable. This message can be cancelled using parameter 'noerr'.
I read the manual and tried even a simpel OjectRef like this:
$TPL->ObjectRef =& $p;
With the following code in my HTML file: [onload;script='tpl/[var.~tpl_dir]/positions/top.php';subtpl]
But the error is the same. I also get this error for every ~something I try to call using this method. If $tpl_dir is a global variable, it works fine, if I define TPL_DIR as a constant and use [var..cst.TPL_DIR] it works file too.
I don't understand why I get this error. $p is an object and has been initialzed but I get that it's type is boolean...
I have been searching for a solution for one day already before posting a question in the fourm... but I'm completely beat by this problem.
Thanks for your help (and particularly to Skrol29 - Merci beaucoup )
OverNode
By: sheepy
Date: 2007-02-23
Time: 05:14

Re: OOP Question... and Problem

[onload] is merged on LoadTemplate, when ObjectRef is not yet assigned.  Either change it to onshow or make the assignment before LoadTemplate.
By: OverNode
Date: 2007-03-02
Time: 08:53

Re: OOP Question... and Problem

Thanks a LOT :)