Categories > TinyButStrong general >

Now I've Really Gone and Done It!

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Maz
Date: 2006-04-14
Time: 04:20

Now I've Really Gone and Done It!

I was happily using 2.02.4 and have been for some time now. Because it was only ever going to be used at our site, I customised it to load a default header and footer, using a path that was set in my init file.

Example:

INIT FILE:

//----------------------------------------------------------
// Set Member template path based on theme in DB
//----------------------------------------------------------
$TBS->GlobalPath = "/templates/".$mbr_config['theme']."/";

Then in the TBS Class:

class clsTinyButStrong {

var $GlobalPath         = "/templates/default/";
var $GlobalExtension    = ".tpl.php";

Then, in the LoadTemplate function:

function LoadTemplate($File,$HtmlCharSet='') {
    // Load the file
    // global $subscriber, $subscriber2;
    global $mbr_config;
    global $in_admincp;
    $x = '';
    $File = $this->GlobalPath.$File.$this->GlobalExtension;
   
    if (!tbs_Misc_GetFile($x,$File)) return $this->meth_Misc_Alert('LoadTemplate Method','Unable to read the file \''.$File.'\'.');
    if($in_admincp == 0)
    {
        $x = '[onload;file=templates/'.$mbr_config['theme'].'/layout/start.tpl.php]'.$x.'[onload;file=templates/'.$mbr_config['theme'].'/layout/end.tpl.php]';
    }
    else
    {
        $x = '[onload;file=templates/'.$mbr_config['theme'].'/layout/admin-start.tpl.php]'.$x.'[onload;file=templates/'.$mbr_config['theme'].'/layout/admin-end.tpl.php]';
    }
   
    // CharSet analysis
    if ($HtmlCharSet==='+') {
        $this->Source .= $x;
    } else {
        $this->Source = $x;
        if ($this->_Mode==0) {
            $this->_LastFile = $File;
            $this->_HtmlCharFct = false;
            $this->TplVars = array();
            if (is_string($HtmlCharSet)) {
                if (($HtmlCharSet!=='') and ($HtmlCharSet[0]==='=')) {
                    $ErrMsg = false;
                    $HtmlCharSet = substr($HtmlCharSet,1);
                    if ($this->meth_Misc_UserFctCheck($HtmlCharSet,$ErrMsg)) {
                        $this->_HtmlCharFct = true;
                    } else {
                        $this->meth_Misc_Alert('LoadTemplate Method',$ErrMsg);
                        $HtmlCharSet = '';
                    }
                }
            } elseif ($HtmlCharSet===false) {
                $this->Protect = false;
            } else {
                $this->meth_Misc_Alert('LoadTemplate Method','CharSet is not a string.');
                $HtmlCharSet = '';
            }
            $this->HtmlCharSet = $HtmlCharSet;
        }
    }
    // Automatic fields and blocks
    $this->meth_Merge_Auto($this->Source,'onload',true,true);
    return true;
    // Load the file
    $x = '';
    $File = $this->GlobalPath.$File.$this->GlobalExtension;
    if (!tbs_Misc_GetFile($x,$File)) return $this->meth_Misc_Alert('LoadTemplate Method','Unable to read the file \''.$File.'\'.');
    // CharSet analysis
    if ($HtmlCharSet==='+') {
        $this->Source .= $x;
    } else {

Which worked a treat. It meant I could use $TBS->LoadTemplate('content/modules/store/edit-license'); in my code and have the header and footer automatically loaded, without having to load it in every page of code.

However, I've just tried the exact same thing in 2.05.7 and it won't work. I know it's asking a lot but if anyone can point me in the right direction, to get the same thing to work, it would be a huge help. It's now pretty crucial to our site code now and I'm a tad stuffed without it.

I've even attached my older modified version at http://www,invisioncube.com/class-tbs.zip
By: Maz
Date: 2006-04-14
Time: 04:28

Re: Now I've Really Gone and Done It!

Should have added, in the 2.05.7 version, it loads the header and footer ok, but not the content.
By: Maz
Date: 2006-04-14
Time: 05:34

Re: Now I've Really Gone and Done It!

I've managed to resolve this and the thread at http://www.tinybutstrong.com/apps/forum/index.php?frm=&thr_id=1185&msg_id=5086#5086 by going through the latest version with a Diff tool and changing little bits.