class Controller_Admin extends Controller_Template { public $template = 'template_admin'; public function action_index() { } // show dashboard [b]public function action_login() { }[/b] public function action_logout() { } public function action_news() { } // show all news items public function ... }
Harro Verton wrote on Sunday 7th of August 2011:Normally, you would use a public base controller for unauthenticated output, and a different one for authenticated output. A login page is per definition unauthenticated, so it's controller would use the public base controller.
Harro Verton wrote on Sunday 7th of August 2011:If you had looked at the code of Controller_Template, you would have seen how it deals with the defined template. And it also makes it very clear how to disable the auto rendering behavior: simply set $this->auto_render to false, in your before(), before calling parent::before().
class Controller_Admin extends Controller_Template { /** * @var string page template */ public $template = 'template_admin'; //-------------------------------------------------------------------------------------------------------- /** * Run this code before every other method in this class * * @param array $data // make Controller_Admin compatible with Controller_Template */ public function before($data = null) { // Make sure the template system works parent::before(); // Not autorendering templates makes it possible to exclude some methods from the template [b]$this->auto_render = false;[/b] // This line of code must be put [b]AFTER[/b] parent::before(); // Load package auth Fuel::add_package('auth'); ... } //-------------------------------------------------------------------------------------------------------- public function action_index() { //load the dashboard $data = array(); $this->template->content = View::factory('admin/index', $data); [b]$this->response->body = $this->template;[/b] // Because we set auto_render to false, you need this line to output your template content } //-------------------------------------------------------------------------------------------------------- public function action_login() { [b]$this->response->body = View::factory('admin/login');[/b] // This method is excluded from the template. } }
Harro Verton wrote on Monday 8th of August 2011:We're working very hard on getting the docs complete, but that's a long process, given the fact that we only have one person available that works on that. Therefore we invite the community to fork the docs repository on github, and make the modifications themselfs when they encounter an omission such as this.
Harro Verton wrote on Monday 8th of August 2011:I mean don't commit to much in one go, with changes that don't belong together, as we have to merge the entire commit when you send us a pull request.
It looks like you're new here. If you want to get involved, click one of these buttons!