【问题标题】:Yii Framework with Twitter Bootstrap not loading带有 Twitter Bootstrap 的 Yii 框架未加载
【发布时间】:2013-03-12 15:42:52
【问题描述】:

我是 Yii 新手,想实现 Twitter Bootstrap 扩展,我关注了 cniska 但显然我做错了什么。

当我在浏览器中加载带有扩展代码的页面时,图像/效果不会加载。

在我的 html 页面中,我找到了这个简单的切换按钮 here

  <?php $this->widget('bootstrap.widgets.TbButton', array(
      'buttonType'=>'button',
      'type'=>'primary',
      'label'=>'Toggle me',
      'toggle'=>true,
  )); ?>

这样的结果就像我刚刚做了一个没有应用任何类的简单 HTML 按钮,一个“裸”样式按钮,所以说吧。

我的配置/main.php:

Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');

return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Test App',

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

// autoloading model and component classes
'import'=>array(
    'application.models.*',
    'application.components.*',
),

'modules'=>array(
    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'<password>',
        'ipFilters'=>array('127.0.0.1','::1'),
    ),
),

'components'=>array(
    'user'=>array(
      'allowAutoLogin'=>true,
  ),
  'bootstrap'=>array(
    'class'=>'bootstrap.components.Bootstrap',
   ),

  'theme'=>'bootstrap', -// requires you to copy the theme under your themes directory
    'modules'=>array(
        'gii'=>array(
            'generatorPaths'=>array(
                'bootstrap.gii',
            ),
        ),
    ),

    'db'=>array(
        'connectionString' => 'mysql:host=localhost;dbname=<bdname>',
        'emulatePrepare' => true,
        'username' => '<bd username>',
        'password' => '<bd password>',
        'charset' => 'utf8',
    ),

    'errorHandler'=>array(
        'errorAction'=>'site/error',
    ),
    'log'=>array(
        'class'=>'CLogRouter',
        'routes'=>array(
            array(
                'class'=>'CFileLogRoute',
                'levels'=>'error, warning',
            ),

        ),
    ),
),

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

我也相信我有最新版本,因为我本周下载了 Yii 的框架以及扩展。 有什么建议吗?

提前致谢

【问题讨论】:

  • 您是否尝试过预加载引导程序,即preload=&gt;array('log','bootstrap')
  • 你可能需要注册css、js。见here
  • 你使用的是哪个版本的 yii-bootstap?
  • 是的,我已经做到了,结果是一样的。

标签: php twitter-bootstrap yii yii-extensions


【解决方案1】:

你需要注册css和js文件, 在主布局中添加这一行

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

【讨论】:

    【解决方案2】:

    您必须更新您的main.config,将其更改为在preload 部分中加载引导程序,如下所示:

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

    或调用@neophile 在您需要的每种情况下编写的代码。

    用户可以查看official guideline 进行初始设置(Initialization options 部分)

    【讨论】:

      猜你喜欢
      • 2013-03-18
      • 2016-08-22
      • 2012-02-14
      • 1970-01-01
      • 1970-01-01
      • 2018-05-27
      • 1970-01-01
      • 1970-01-01
      • 2012-01-17
      相关资源
      最近更新 更多