php - Kohana - Views Within Views -
i have problem passing variables through views. but, first code
// enter 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 pass variables 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 try in display view try "echo" variables:
// views/default.php echo $head; echo $nav; echo $header; echo $sidebar; echo $content; echo $footer;
and throw error:
errorexception [ 2 ]: file_put_contents(/some_path/application/logs/2011/02/23.php): failed open stream: permission denied ~ syspath/classes/kohana/log/file.php [ 81 ]
if write that:
// views/default.php include kohana::find_file('views', 'default');
it display valid;
chmod 777 /some_path/application/logs/2011/02/23.php
file , 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);
Comments
Post a Comment