I have controller Blog
<?php namespace Blog;
use \Response;
use \View;
use \Uri;
class Controller_Blog extends \Controller {
protected static $view = null;
protected static $theme = 'default';
public function before() {
// Get view
self::$view = View::forge('themes/'.self::$theme.'/index.twig');
}
public function action_index() {
$posts = Model_Posts::find('all');
// Assign views as variables, lazy rendering
self::$view->content = View::forge('posts.twig')->set('posts', $posts);
// Return the view object to the Request
return self::$view;
}
}
Here is index.twig
{% include "header.twig" %}
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
Sidebar
</div>
<div class="span10">
{{content}}
</div>
</div>
</div>
{% include "footer.twig" %}
I have header.twig and footer.twig, but for some strange reason second {% include "footer.twig" %} dosnt work! I can use just one include.
Works fine {% include "header.twig" %}
Dosnt work {% include "footer.twig" %} I have got errors:
Twig_Error_Loader [ Error ]: Unable to find template "footer.twig" (looked into:
......\fuel\app\modules\blog\views
Why ? Why FuelPHP(with twig parser) try to load footer.twig view from \fuel\app\modules\blog\views but not from \fuel\app\views\themes\default as for header.twig ?
Never used it, I'm afraid.
However, did you compare the performance with and without it?
I know this wasn't the original question but, are you sure you need a template system besides what you already have in fuel?
I have no problems with multiple includes. It work's perfectly nice.
But i have an other issue with parser/twig/theme class. If i extend a template via {% extends "backend/template.twig" %} (file backend/template.twig in my active theme) it only searches the active-theme and app/views for the file but not the fallback theme for the file. How can i force it to do so?
Sorry for using this threat but the topic perfectly fits.