I would like to pass some data from my Controller_Template
to my template.php
.
Here's my controller:
class Controller_User extends Controller_Template {
public $template = 'template';
public function action_index() {
$user = "Alice";
$view = View::factory('user/user')
->bind('user', $user);
$this->template->content = $view;
}
}
Doing this means I can access $user
in user/user.php
, and whatever markup I have in user/user.php
is available in $content
.
However, I want to access $user
in template.php
. If I change the bind()
method to bind_global('user', $user)
then I can indeed access $user
in template.php
.
The problem though, is that if I do that, there seems to be nothing in $content
. Where am I going wrong?