public function action_index() { $view = View::factory('layout'); $view->head = View::factory('header'); $view->content = View::factory('welcome/index'); $this->output = $view; }Now the browser output is blank with no errors and no source code. What am i doing wrong?
<?php echo $head; ?> <?php echo $content; ?>
class Controller_Test extends Controller_Template { // This will make your template file views/template/someview.php public $template = 'template/someview'; public function action_index() { // File under views/partials/header.php $this->template->header = View::factory('partials/header'); $this->template->footer = 'this is a footer string, could also be a view file'; } }
<html> <head> <title>My first template</title> </head> <body> <h1>welcome</h1> <div class="header"> <?=$header?> </div> <div class="main"> if you assigned a $main variable in your controller (i.e. $this->template->main = 'something' you could echo $main here. there is no limit to how many template properties you have you could have $this->template->roflmao_nerdburger = 'haha' in your view and just echo $roflmao_nerdburger here. </div> <div class="footer"> <?=$footer?> </div> </body> </html>
public function action_index() { $view = View::factory('layout'); $view->head = View::factory('header'); $view->content = View::factory('welcome/index'); $this->response->body = $view; }
It looks like you're new here. If you want to get involved, click one of these buttons!