title: Kohana - Views Within Views
body: <p>I have problem with passing variables through views. But, first some code</p>
  
  <pre><code>// i enter the url http://localhost/my_projects/blog/index/index
  // classes/controller/index.php
  class Controller_Index extends Controller
  {
      protected $rendered_view;
  
      public function before()
      {
          $this-&gt;rendered_view = View::factory('index')
                  -&gt;set('head', View::factory('subpages/head')
                                 -&gt;set('title', 'Site title')
                       )
                  -&gt;set('nav', View::factory('subpages/nav')
                                 -&gt;set('title', 'Site title')
                       )
                  -&gt;set('header', View::factory('subpages/header')
                                  -&gt;set('h1', 'Header H1')
                       )
                  -&gt;set('sidebar', View::factory('subpages/sidebar')
                                  -&gt;set('h1', 'Header H1')
                       )
                  -&gt;set('content', View::factory('subpages/content')
                                  -&gt;set('h2', 'Header H2')
                                  -&gt;set('content', 'some content')
                       )
                  -&gt;set('footer', View::factory('subpages/footer')
                                  -&gt;set('footer', 'some footer')
                       );
      }
  
      public function action_index()
      {
          $this-&gt;response-&gt;body($this-&gt;rendered_view);
      }
  }
  </code></pre>
  
  <p>And in view index i pass variables to the default view:</p>
  
  <pre><code>// views/index.php
  echo View::factory('default')-&gt;set('head', $head);
  echo View::factory('default')-&gt;set('nav', $nav);
  echo View::factory('default')-&gt;set('header', $header);
  echo View::factory('default')-&gt;set('sidebar', $sidebar);
  echo View::factory('default')-&gt;set('content', $content);
  echo View::factory('default')-&gt;set('footer', $footer);
  </code></pre>
  
  <p>And i try in display view i try "echo" variables:</p>
  
  <pre><code>// views/default.php
  echo $head; 
  echo $nav; 
  echo $header; 
  echo $sidebar; 
  echo $content; 
  echo $footer;
  </code></pre>
  
  <p>And it throw error:</p>
  
  <pre><code>ErrorException [ 2 ]: file_put_contents(/some_path/application/logs/2011/02/23.php): failed to open stream: Permission denied ~ SYSPATH/classes/kohana/log/file.php [ 81 ]
  </code></pre>
  
  <p>If i write something like that:</p>
  
  <pre><code>// views/default.php
  include Kohana::find_file('views', 'default');
  </code></pre>
  
  <p>it display valid;</p>