2013-02-28 15 views
0

我已經設法在我的測試yii安裝上創建了「Testdrive」應用程序。我認爲我已經安裝了Bootstrap。試圖在Yii中激活主題並安裝Bootstrap

更重要的是我努力激活我想使用的主題。我已經通過了所有我能找到的Yii教程,並且已經改變了'theme' => 'xxxx'沒有成功。

我已經仔細檢查了文件/文件夾權限以消除明顯的錯誤。

的URL查看演示現場直播是http://www.pureads.co.uk/testdrive

隨意問我什麼,我會回答,盡我所能。

這是我protected/config/main.php文件中,我有試圖在我已經坐在/testdrive/themes但似乎並沒有被工作主題,以調用。

<?php 

// uncomment the following to define a path alias 
// Yii::setPathOfAlias('local','path/to/local-folder'); 

// 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.*', 
    ), 
    'modules'=>array(
     // uncomment the following to enable the Gii tool 

     'gii'=>array(
      'class'=>'system.gii.GiiModule', 
      'password'=>'Enter Your Password Here', 
      // 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, 
     ), 
     // 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]', 
    ), 
    'theme'=>'andia-agency', // requires you to copy the theme under your themes directory 
    'modules'=>array(
     'gii'=>array(
      'generatorPaths'=>array(
       'bootstrap.gii', 
      ), 
     ), 
    ), 
    'components'=>array(
     'bootstrap'=>array(
      'class'=>'bootstrap.components.Bootstrap', 
     ), 
    ), 
); 
+0

'themes/andia-agency'文件夾的內容是什麼?並記住安裝bootstrap,你不必重複'components'屬性 – dInGd0nG 2013-02-28 14:51:43

+0

有一個名爲Assets的文件夾和五個叫做about,contact,index,portfolio&services的html文件。在Assets文件夾中有文件夾叫做bootstrap,css,font-awesome,ico,img,js和prettyPhoto以及一個名爲sendmail.php的文件。謝謝。 – Ross 2013-02-28 15:04:06

+0

最近我遇到了主題頭疼的問題,發現調試XDebug幫助很大 – acorncom 2013-03-01 01:01:10

回答

2

主題文件夾應該具有相同的結構,你保護/視圖/文件夾。所以你的主題應該設置如下(相對於當然根目錄)。

  • 主題
    • 意見
    • 佈局
    • 網站

有時我得到的 '主題' 配置選項的工作權利的問題。通常我在CController :: beforeAction($ action)中的控制器中添加以下內容;

Yii::app()->setTheme('andia-agency'); 
1

是否包含

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

到您的<head></head>部分?

這對我有效。 :)

0

您的引導主題安裝不正確。正確的方法在yii-bootstrap setup中描述。所以當你看到那裏,你必須在你的config/main.php文件的第一個文件中定義它的地址,如下所示:

// Define a path alias for the Bootstrap extension as it's used internally. 
// In this example we assume that you unzipped the extension under protected/extensions. 
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap'); 
return array(
'theme'=>'bootstrap', // requires you to copy the theme under your themes directory 
'modules'=>array(
    'gii'=>array(
     'generatorPaths'=>array(
      'bootstrap.gii', 
     ), 
    ), 
), 
'components'=>array(
    'bootstrap'=>array(
     'class'=>'bootstrap.components.Bootstrap', 
    ), 
), 
);