Changeset 3275 for trunk/application

Show
Ignore:
Timestamp:
08/06/2008 08:31:35 AM (4 months ago)
Author:
Shadowhand
Message:

Updated welcome controller to use the default kohana template added in r3274

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/welcome.php

    r2622 r3275  
    99 * @license    http://kohanaphp.com/license.html 
    1010 */ 
    11 class Welcome_Controller extends Controller { 
     11class Welcome_Controller extends Template_Controller { 
    1212 
    1313        // Disable this controller when Kohana is set to production mode. 
     
    1515        const ALLOW_PRODUCTION = FALSE; 
    1616 
     17        // Set the name of the template to use 
     18        public $template = 'kohana/template'; 
     19 
    1720        public function index() 
    1821        { 
    1922                // In Kohana, all views are loaded and treated as objects. 
    20                 $welcome = new View('welcome'); 
     23                $this->template->content = new View('welcome'); 
    2124 
    2225                // You can assign anything variable to a view by using standard OOP 
    2326                // methods. In my welcome view, the $title variable will be assigned 
    2427                // the value I give it here. 
    25                 $welcome->title = 'Welcome to Kohana!'; 
     28                $this->template->title = 'Welcome to Kohana!'; 
    2629 
    2730                // An array of links to display. Assiging variables to views is completely 
    2831                // asyncronous. Variables can be set in any order, and can be any type 
    2932                // of data, including objects. 
    30                 $welcome->links = array 
     33                $this->template->content->links = array 
    3134                ( 
    3235                        'Home Page'     => 'http://kohanaphp.com/', 
     
    3639                        'Donate'        => 'http://kohanaphp.com/donate.html', 
    3740                ); 
    38  
    39                 // Using views inside of views is completely transparent. In the welcome 
    40                 // view, printing the $content variable will render the welcome_content view. 
    41                 $welcome->content = new View('welcome_content'); 
    42  
    43                 // Using render(TRUE) forces the view to display now, instead of 
    44                 // returning an HTML string. 
    45                 $welcome->render(TRUE); 
    4641        } 
    4742 
    4843        public function _default() 
    4944        { 
     45                // Disable auto-rendering 
     46                $this->auto_render = FALSE; 
     47 
    5048                // By defining a method called _default, all pages routed to this controller 
    5149                // that result in 404 errors will be handled by this method, instead of 
     
    5452        } 
    5553 
    56 } 
     54} // End Welcome Controller