twitter-bootstrap 如何在 Yii 中使用引导程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14125201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 16:01:39  来源:igfitidea点击:

how to use bootstrap with Yii?

phptwitter-bootstrapyii

提问by Sahil

I have been trying to implement twitter bootstrap extension in Yii but cannot do it.

我一直在尝试在 Yii 中实现 twitter bootstrap 扩展,但无法做到。

I am following the guide below to install it with Yii.

我正在按照下面的指南使用 Yii 安装它。

http://www.cniska.net/yii-bootstrap/setup.html

http://www.cniska.net/yii-bootstrap/setup.html

I copied and pasted the following code in my main config file as described in above guide.

我将以下代码复制并粘贴到我的主配置文件中,如上述指南中所述。

// 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',
    ),
),
);

Can anyone please help.

任何人都可以请帮忙。

回答by Sahil

Found the answer you need to put the following in your main.php file of your protected/views/layouts folder anywhere between <head>and </head>tag.

找到了您需要将以下内容放在您的 protected/views/layouts 文件夹中的 main.php 文件中<head></head>标记之间的任何位置的答案。

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

回答by Taran

It worked for me like a piece of cake. I guess problem with you is your path to bootstrap extension. I would suggest to put complete path instead of relative path. Once it get working you can try to make the path relative.

它对我来说就像小菜一碟。我想你的问题是你的引导程序扩展路径。我建议放置完整路径而不是相对路径。一旦它开始工作,您可以尝试使路径相对。

Example: Yii::setPathOfAlias('bootstrap', '/var/www/yoursite/application/extensions/bootstrap');

示例: Yii::setPathOfAlias('bootstrap', '/var/www/yoursite/application/extensions/bootstrap');

Instead of: Yii::setPathOfAlias('bootstrap', dirname(FILE).'/../extensions/bootstrap');

而不是: Yii::setPathOfAlias('bootstrap', dirname( FILE).'/../extensions/bootstrap');

This should work for you! Cheers!!!

这应该对你有用!干杯!!!

回答by karthik

I am also use that but the answer is not come but I got another way so you follow that I tell.

我也在使用它,但没有得到答案,但我有另一种方法,所以你按照我说的去做。

I think you want new themes so"

我想你想要新的主题所以”

  1. Go to download themes from yii framework.
  2. Copy that folder then past to themes folder
  3. config->main.php->'theme'=>'grey-stripes', protected go config folder go main.php go and copy 'theme'=>'grey-stripes',
  1. 去 yii 框架下载主题。
  2. 复制该文件夹然后粘贴到主题文件夹
  3. config->main.php->'theme'=>'grey-stripes', 受保护的 go config 文件夹 go main.php 去复制 'theme'=>'grey-stripes',

Your new themes are ready

您的新主题已准备就绪