Show
Ignore:
Timestamp:
02/08/2008 07:20:03 PM (11 months ago)
Author:
Shadowhand
Message:

Updated default welcome controller and views. Much more attractive now.

Files:
1 modified

Legend:

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

    r1522 r2004  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    22/** 
     3 * @package Core 
     4 * 
    35 * Default Kohana controller. 
    46 */ 
     
    79        public function index() 
    810        { 
     11                // In Kohana, all views are loaded and treated as objects. 
    912                $welcome = new View('welcome'); 
    10                 $welcome->message = 'This is the default Kohana index page. You can edit <tt>application/controllers/welcome.php</tt> now.'; 
     13 
     14                // You can assign anything variable to a view by using standard OOP 
     15                // methods. In my welcome view, the $title variable will be assigned 
     16                // the value I give it here. 
     17                $welcome->title = 'Welcome to Kohana!'; 
     18 
     19                // An array of links to display. Assiging variables to views is completely 
     20                // asyncronous. Variables can be set in any order, and can be any type 
     21                // of data, including objects. 
     22                $welcome->links = array 
     23                ( 
     24                        'License' => url::base(FALSE).'Kohana License.html', 
     25                        'Home Page' => 'http://kohanaphp.com/', 
     26                        'Documentation' => 'http://doc.kohanaphp.com/', 
     27                        'Forum' => 'http://forum.kohanaphp.com/', 
     28                ); 
     29 
     30                // Using views inside of views is completely transparent. In the welcome 
     31                // view, printing the $content variable will render the welcome_content view. 
     32                $welcome->content = new View('welcome_content'); 
     33 
     34                // Using render(TRUE) forces the view to display now, instead of 
     35                // returning an HTML string. 
    1136                $welcome->render(TRUE); 
    1237        } 
    1338 
     39        public function _default() 
     40        { 
     41                // By defining a method called _default, all pages routed to this controller 
     42                // that result in 404 errors will be handled by this method, instead of 
     43                // being displayed as "Page Not Found" errors. 
     44                echo 'This is a _default handler. If you expected the index page, you need to use: welcome/index/'.substr(Router::$current_uri, 8); 
     45        } 
     46 
    1447}