2014-05-05 38 views
1

我想綁定引導與yii,從這裏下載一個包。 http://www.cniska.net/yii-bootstrap/,Have經歷了那裏提供的步驟,但它不適合我。帶自舉的Yii。?

enter image description here

我有以下文件結構。

我的配置/ main.php就像。

<?php 


// uncomment the following to define a path alias 
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap'); 

// This is the main Web application configuration. Any writable 
// CWebApplication properties can be configured here. 

return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 
    'name'=>'My Web Application', 

    // preloading 'log' component 
    'preload'=>array('log'), 

    // autoloading model and component classes 
    'import'=>array(
     'application.models.*', 
     'application.components.*', 
    ), 
     'theme'=>'bootstrap', // requires you to copy the theme under your themes directory 
    'modules'=>array(
     // uncomment the following to enable the Gii tool 

     'gii'=>array(
      'class'=>'system.gii.GiiModule', 
      'password'=>'12345', 
      // If removed, Gii defaults to localhost only. Edit carefully to taste. 
      'ipFilters'=>array('127.0.0.1','::1'), 
     ), 

    ), 




    // application components 
    'components'=>array(
     'user'=>array(
      // enable cookie-based authentication 
      'allowAutoLogin'=>true, 
     ), 

        'bootstrap'=>array(
      'class'=>'bootstrap.components.Bootstrap', 
     ), 
     // uncomment the following to enable URLs in path-format 
     /* 
     'urlManager'=>array(
      'urlFormat'=>'path', 
      'rules'=>array(
       '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
       '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
       '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
      ), 
     ), 
     */ 
     'db'=>array(
      'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', 
     ), 
     // uncomment the following to use a MySQL database 
     /* 
     'db'=>array(
      'connectionString' => 'mysql:host=localhost;dbname=testdrive', 
      'emulatePrepare' => true, 
      'username' => 'root', 
      'password' => '', 
      'charset' => 'utf8', 
     ), 
     */ 
     'errorHandler'=>array(
      // use 'site/error' action to display errors 
      'errorAction'=>'site/error', 
     ), 
     'log'=>array(
      'class'=>'CLogRouter', 
      'routes'=>array(
       array(
        'class'=>'CFileLogRoute', 
        'levels'=>'error, warning', 
       ), 
       // uncomment the following to show log messages on web pages 
       /* 
       array(
        'class'=>'CWebLogRoute', 
       ), 
       */ 
      ), 
     ), 
    ), 

    // application-level parameters that can be accessed 
    // using Yii::app()->params['paramName'] 
    'params'=>array(
     // this is used in contact page 
     'adminEmail'=>'[email protected]', 
    ), 
); 

我有一個主視圖,但我無法看到頁面。 這是代碼。

<?php /* @var $this Controller */ ?> 
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta name="language" content="en" /> 

    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/styles.css" /> 

    <title><?php echo CHtml::encode($this->pageTitle); ?></title> 

    <?php Yii::app()->bootstrap->register(); ?> 
</head> 

<body> 

<?php $this->widget('bootstrap.widgets.TbNavbar',array(
    'items'=>array(
     array(
      'class'=>'bootstrap.widgets.TbMenu', 
      'items'=>array(
       array('label'=>'Home', 'url'=>array('/site/index')), 
       array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')), 
       array('label'=>'Contact', 'url'=>array('/site/contact')), 
       array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest), 
       array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest) 
      ), 
     ), 
    ), 
)); ?> 

<div class="container" id="page"> 

    <?php if(isset($this->breadcrumbs)):?> 
     <?php //$this->widget('bootstrap.widgets.TbBreadcrumbs', array(
      //'links'=>$this->breadcrumbs, 
     //)); ?><!-- breadcrumbs --> 
    <?php endif?> 

    <?php echo $content; ?> 

    <div class="clear"></div> 

    <div id="footer"> 
     Copyright &copy; <?php echo date('Y'); ?> by My Company.<br/> 
     All Rights Reserved.<br/> 
     <?php echo Yii::powered(); ?> 
    </div><!-- footer --> 

</div><!-- page --> 

</body> 
</html> 

我有一個索引頁,我沒有任何css或菜單。

view.php

<?php 

/* @var $this SiteController */ 
$this->pageTitle=Yii::app()->name; 
?> 

<?php $this->beginWidget('bootstrap.widgets.TbHeroUnit',array(
    'heading'=>'Welcome to '.CHtml::encode(Yii::app()->name), 
)); ?> 

<p>Congratulations! You have successfully created your Yii application.</p> 

<?php $this->endWidget(); ?> 

<p>You may change the content of this page by modifying the following two files:</p> 

<ul> 
    <li>View file: <code><?php echo __FILE__; ?></code></li> 
    <li>Layout file: <code><?php echo $this->getLayoutFile('main'); ?></code></li> 
</ul> 

<p>For more details on how to further develop this application, please read 
    the <a href="http://www.yiiframework.com/doc/">documentation</a>. 
    Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>, 
    should you have any questions.</p> 

我沒有得到所需的佈局...可能是上述信息不sufficent回答我的問題,將提供額外的信息,如果問。

+0

一切正常。你有沒有試過任何瀏覽頁面? – Babu

+0

剛剛編輯ny的問題..看一看 – saji

+0

其不加載main.php – saji

回答

1

此外,在預壓加引導:

'preload'=>array('log','bootstrap'), 
0

增加@Ronit阿迪卡里答案,我不記得很清楚,但我覺得有像

Yii::app()->bootstrap->register(); 

一條線,你有把它放在你想要使用的地方,就像在主佈局中一樣。

+0

yah @tinybyte如果你有多個主題比這是有用的 –

+0

只是編輯我的問題...看看。 – saji