O'Reilly logo

Yii Project Blueprints by Charles R. Portwood II

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the presentation layer

Now, we're ready to start displaying content. To get started, we create a new controller called SiteController.php in the protected/controllers directory that contains the following:

<?php
class SiteController extends CController
{
   public function actionIndex()
   {
        $this->render('index');
   }
}

Next, let's create our main layout in protected/views/layouts/main.php. For simplicity, we're once again going to use the jQuery and Twitter Bootstrap styles from publicly available CDNs, as follows:

<!DOCTYPE html> <html> <head> <title><?php echo CHtml::encode(Yii::app()->name); ?></title> <?php Yii::app()->clientScript ->registerMetaTag('text/html; charset=UTF-8', 'Content-Type') ->registerCssFile( '//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required