Boilerplate recommends using @import when adding styles to the head.
<style>@import(/example.css);</style>
Yii uses the ClientScript model to add
<link type="text/css" src="/example.css" />
Use the program Yii :: app () → clientScript to register the file. Yii allows you to register script files as needed, per controller or per view. Therefore, your HTTP requests may be minimal. I would suggest registering the necessary scripts / css in the main layout and adding other scripts that are needed with
Yii::app()->clientScript->registerScriptFile();
Yii is based on the MVC model. V to view. View folds contain html elements that your model and controller will customize based on data types. Inside the view folder, Yii uses the layout folder to define layouts.
$this->layout = 'main';
This line will look for:
Protected -> views -> layout -> main.php
The layout folder should contain the main ones, _htmlHead, _header and _footer. RenderPartial will be used to render various parts of the layout. This is similar to php for HTML. The second parameter $ this-> render or $ this-> renderPartial is used to transfer data to the view. For example, navigation data:
$this->renderPartial('_footer', array('nav'=>array('/link/'=>'Link Name')));
In _htmlHead, register the required elements using Yii :: app () -> clientScript. If you want to use a different version of jQuery, then use the ScriptMap model, do not register jQuery twice. Yii coreScript, validation and swapping are based on jQuery.
$cs = Yii::app()->clientScript; $cs->registerCssFile('/css/base.css'); $cs->registerScriptFile('/js/base.js', CClientScript::POS_END);
http://www.yiiframework.com/doc/api/1.1/CClientScript
In the past, I used the config.php file in Yii to set the assetLocaion parameter. If I transfer my assets, he will not break the site.
Yii::app()->clientScript->registerScriptFile(Yii::app()->param->assetsLocation.'/js/example.js');
The main layout of the template will be defined in the layout /main.php. Check the related documentation: http://www.yiiframework.com/doc/guide/1.1/en/topics.theming
The layout file might look like this:
<!doctype html> <?php $this->renderPartial('//layouts/_Htmlhead); ?> <body> <div id="container"> <?php $this->renderPartial(' <div id="main" role="main"> <?php echo $content; ?> </div> <?php $this->renderPartial('//layouts/_footer); ?> </div> <?php $this->renderPartial(' </body> </html>