<?php defined('SYSPATH') or die('No direct script access.'); class Controller_Hmvc extends Controller_DefaultTemplate { public function action_index() { // Set meta data $this->template->title = 'Kohana 3.0 HMVC Test'; $this->template->meta_keywords = 'PHP, Kohana, KO3, Framework, HMVC'; $this->template->meta_description = 'A test of of the KO3 framework HMVC pattern'; // Fill in content $ko3 = array(); $ko3['posts'] = Request::factory('posts/getposts')->execute()->response; $this->template->content = View::factory('pages/hmvc', $ko3); } }
$ko3['posts'] = Request::factory('posts/getposts')->execute()->response;
<?php echo $posts;?>
<?php defined('SYSPATH') or die('No direct script access.'); class Controller_Posts extends Controller { public function action_index() { } public function action_getposts() { // Load model $posts = new Model_Post(); // Fill content array for view with last 10 posts. $content = array(); $content['posts'] = $posts->getLastTenPosts(); // Render and output. $this->request->response = View::factory('pages/hmvc_posts', $content); } }
<?php foreach($posts as $post):?> <h1><?php echo $post['title'];?></h1> <?php echo $post['post'];?> <hr /> <?php endforeach;?>
<?php defined('SYSPATH') or die('No direct script access.'); class Controller_Hmvc extends Controller_DefaultTemplate { public function action_index() { // Set meta data $this->template->title = 'Kohana 3.0 HMVC Test'; $this->template->meta_keywords = 'PHP, Kohana, KO3, Framework, HMVC'; $this->template->meta_description = 'A test of of the KO3 framework HMVC pattern'; // Fill in content $ko3 = array(); $ko3['content'] = 'Hello there!'; $this->template->content = View::factory('pages/hmvc', $ko3); } }
<?php echo $content;?><br/> <?php echo Request::factory('posts/getposts')->execute()->response;?>
Source: https://habr.com/ru/post/111959/
All Articles