I've created a really basic Controller as you can see below:-
class Controller_Users extends Controller_Template {
public function action_index()
{
$this->template->title = 'Homepage';
$this->template->content = View::factory('index');
}
public function action_register()
{
$this->template->title = 'Register';
$this->template->content = View::factory('register');
}
}
As expected the index view loads fine but when I click on the 'Register' link on the homepage the register view is not loaded, instead I get the 'Undefined variable: content' notice? Could someone explain what I'm doing wrong please?
I had it working fine when I was using:-
$this->response->body = View::factory('index', $data);
But now I want to use Fuel's template view. Sorry this is really basic but I'm new to FuelPHP and PHP frameworks as a whole!
All my view files are in the View folder currently:-
Views
- index.php
- register.php
- login.php
Are you referring to the routes.php file in the 'config' folder? If so then no.
Mmm... Reading your post it seems to be a perfect work...
I think is a little mistake, but it's difficult to find... Can you poste some more code? Like file route.php, you controller and view? http://scrp.at/
Solved!
Just as I was about to reply listing my code I noticed in the template.php view file I was calling <a href="index/register">Register</a> when in fact it should be <a href="users/register">Register</a>.
Thanks for your help anyway.