By: Manish
Date: 2016-10-16
Time: 18:55
|
the key 'pagetitle' does not exist or is not set in VarRef
Hi,
I am using AltoRouter for my project. I recently added TBS for templating. This is my index.
<?php
include 'library/AltoRouter.php';
$router = new AltoRouter();
$router->setBasePath('/tbss');
$router->map('GET','/', function() {require __DIR__ . '/catalog/controller/home.php';}, 'home');
$router->map('GET','/aboutus/', function() {require __DIR__ . '/catalog/controller/aboutus.php';}, 'aboutus');
$match = $router->match();
if( $match && is_callable( $match['target'] ) ) {
call_user_func_array( $match['target'], $match['params'] );
} else {
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}
|
The home.php on catalog/controller/home.php
<?php
$pagetitle = 'Hiya';
// Merging main template
include_once('tbs_class.php');
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('catalog/view/template/common/home.htm');
$TBS->Show();
?>
|
and finally the home.htm in catalog/view/template/common
[onload;file='header.htm';]
[onshow.pagetitle;]
[onload;file='footer.htm';]
|
When I run I get an error which says "TinyButStrong Error in field [onshow.pagetitle...]: the key 'pagetitle' does not exist or is not set in VarRef. (VarRef seems refers to $GLOBALS) This message can be cancelled using parameter 'noerr'.".
I do not understand why. Can you help please.
Note: If i remove the altorouter and get the home page on the root directory, rename it index and then run the code it works fine as expected.
|
By: Skrol29
Date: 2016-10-16
Time: 23:18
|
Re: the key 'pagetitle' does not exist or is not set in VarRef
Hi,
It seems that your script "home.htm" is called in a scope that is not global. That happens if the script is called from a function for example.
So the variable $pagetitle is local, not global. TBS cannot reach it.
Simply add
before $pagetitle = 'Hiya';
|
By: Manish
Date: 2016-10-17
Time: 05:29
|
Re: the key 'pagetitle' does not exist or is not set in VarRef
Thank you Skrol. You are kind. It worked. Just 1 more thing. I know you have example listed on the site but is there a book that I can buy for TBS?.
|
By: Skrol29
Date: 2016-10-17
Time: 22:51
|
Re: the key 'pagetitle' does not exist or is not set in VarRef
Hi,
There is no book as I know, sorry.
The examples are also provided in the package you've downloaded.
|
By: Rudolf
Date: 2017-02-04
Time: 12:43
|
Re: the key 'pagetitle' does not exist or is not set in VarRef
Maybe you should write one, Skrol ;)
|
|
Posting in progress.
Please wait...
|