View Single Post
Old 12-20-2007, 07:44 PM   #5 (permalink)
Andrew
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
This is going off topic, but Kohana takes the View as just another object to be manipulated. Member variables can be set dynamically which are then available in the templates files. For example:

PHP Code:
// Code in Controller
$view = new View('mytemplate');
$view->myVar = 'myData';
$view->render(TRUE);

// In the template
<strong><?php echo $myVar; ?></strong>

Back to the original topic, chances are that you're looking at an issue of scope. The header appears to be loaded inside of a class method (on the $tpl object) so the global variables ($user, $site ...) will not be available unless you're using 'global $site' to provide access, or $GLOBALS['site'], or passing those into the template class/methods.

For a test, you could try and var_dump($site) (from inside the header() method) just to see if the object is available to use.
It's displaying "NULL". In my class declarations for $user, $site, how do I declare those as global? Like this?
PHP Code:
global $var;
$var = new Class; 
Edit: Tried that, and still isn't working.
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote