$views = array();
$views['header'] = View::forge('header')->render();
$views['menu'] = View::forge('menu')->render();
$views['content'] = View::forge('content')->render();
$views['footer'] = View::forge('footer')->render();
return View::forge('wrapper', $views)->render();
<?php var_dump($header); ?>
<?php echo $header; ?>
<?php echo $menu; ?>
<?php if(!empty($featured)): ?>
<div id="feature-box">
<?php echo render('featured'); ?>
</div>
<?php endif; ?>
<?php echo $content; ?>
<?php echo $footer; ?>
'security' => array(
'csrf_autoload' => false,
'csrf_token_key' => 'fuel_csrf_token',
'csrf_expiration' => 0,
'uri_filter' => array('htmlentities'),
/**
* This input filter can be any normal PHP function as well as 'xss_clean'
*
* WARNING: Using xss_clean will cause a performance hit. How much is
* dependant on how much input data there is.
*/
'input_filter' => array(),
/**
* Whether to automatically encode (htmlentities) view data
*/
'auto_filter_output' => false,
/**
* With output encoding switched on all objects passed will be converted to strings or
* throw exceptions unless they are instances of the classes in this array.
*/
'whitelisted_classes' => array('Fuel\\Core\\View', 'Fuel\\Core\\ViewModel', 'Closure')
),
parent::before();
$this->template->header = View::forge('header');
$this->template->menu = View::forge('menu');
$this->template->content = Request::forge(Uri::string())->execute();
$this->template->footer = View::forge('footer');
$total_articles = Model_Article::find()->count();
Pagination::set_config(array(
'pagination_url' => 'admin/articles',
'per_page' => 10,
'total_items' => $total_articles,
'num_links' => 5,
'uri_segment' => 3
));
$data['articles'] = Model_Article::find('all', array(
'offset' => Pagination::$offset,
'limit' => Pagination::$per_page
));
$this->template->title = "Article";
return View::forge('admin/articles/index', $data);
My best guess is that I need to stop using Controller_Template, and just handle the wrapper on my own. I *don't* want to have to assign the header, footer, etc in every single method. I'd rather do this in exactly one place across my entire app (for obvious reasons). I don't really need the set_global stuff.
To outline what I'd like to do:
1) I'd like to just return partials in each controller, if at all possible. This will make it very easy to implement AJAX. I feel the best way to do this is using HMVC to request the controller when it's an AJAX request.OutOfBoundsException [ Error ]: View variable is not set: content
<?php
class Controller_Ajax extends Controller_Wrapper {
public function router() {
$this->is_ajax = true;
$segments = Uri::segments();
array_shift($segments); // remove ajax
$path = implode('/', $segments);
$output['html'] = Request::forge($path)->execute();
var_dump($output);
}
}
public function after($response) {
// If the request is ajax, we want to return the content
if(!$this->is_ajax) {
parent::after($response);
} else {
$this->template->get('content');
}
}
$view = View::forge('admin/articles/index', $data);
if(Request::main() === Request::active()) {
$this->template->title = "Article";
}
$this->template->content = $view;
return View::forge('wrapper', $views, false);
I removed the calls to ->render() and I'm still getting the same error. Any ideas? It looks like you're new here. If you want to get involved, click one of these buttons!