开发者

Kohana - Views Within Views

I have problem with passing variables through views. But, first some 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->rendered_view = View::factory('index')
                ->set('head', View::factory('subpages/head')
                               ->set('title', 'Site title')
                     )
                ->set('nav', View::factory('subpages/nav')
                               ->set('title', 'Site title')
                     )
                ->set('header', View::factory('subpages/header')
                                ->set('h1', 'Header H1')
                     )
                ->set('sidebar', View::factory('subpages/sidebar')
                                ->set('h1', 'Header H1')
                     )
                ->set('content', View::factory('subpages/content')
                                ->set('h2', 'Header H2')
                                ->set('content', 'some content')
                     )
                ->set('footer', View::factory('subpages/footer')
                                ->set('footer', 'some footer')
                     );
    }

    public function action_index()
    {
        $this->response->body($this->rendered_view);
    }
}

And in view index i pass variables to the default view:

// views/index.php
echo View::factory('default')->set('head', $head);
echo View::factory('default')->set('nav', $nav);
echo View::factory('default')->set('header', $header);
echo View::factory('default')->set('sidebar', $sidebar);
echo View::factory('default')->set('content', $content);
echo View::factory('default')->set('footer', $footer);

And i try in display view i try "echo" variables:

// views/default.php
echo $head; 
echo $开发者_运维技巧nav; 
echo $header; 
echo $sidebar; 
echo $content; 
echo $footer;

And it throw error:

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 ]

If i write something like that:

// views/default.php
include Kohana::find_file('views', 'default');

it display valid;


chmod 777 /some_path/application/logs/2011/02/23.php file and all directory /some_path/application/logs/ recursively

UPD:

maybe

// views/index.php
echo View::factory('default')
->set('head', $head)
->set('nav', $nav)
->set('header', $header)
->set('sidebar', $sidebar)
->set('content', $content)
->set('footer', $footer);


What's happening is Kohana is throwing an exception and trying to log the error, but can't save the log file.

Make sure /application/logs is writable (755, or 777 on some servers)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜