HTML5Boilerplate with Yii Framework

Has anyone been able to integrate the HTML5 Boilerplate into the YII PHP Framework (in particular, the folder structure and build process)?

+4
source share
5 answers

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); /* Load Script at END of DOM tree: 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('//layouts/_header); ?> <div id="main" role="main"> <?php echo $content; ?> </div> <?php $this->renderPartial('//layouts/_footer); ?> </div> <?php $this->renderPartial('//layouts/_footerScripts); ?> </body> </html> 
+5
source

Check out my integration with Yii BoilerPlate and Bootstrap

https://github.com/drumaddict/YiiApp

+3
source

The simple Yii HTML5 Boilerplate theme is available at https://github.com/neam/yii-html5-boilerplate

+1
source

There is a very detailed Wiki article by Antonio Ramirez entitled:

YiiBoilerplate - setting up a professional project structure in seconds http://www.yiiframework.com/wiki/374/yiiboilerplate-setup-a-professional-project-structure-in-seconds/

Sources for this setup: https://github.com/clevertech/YiiBoilerplate

+1
source

How about https://github.com/clevertech/YiiBoilerplate
I think they use HTML5Bilerplate

0
source

Source: https://habr.com/ru/post/1391877/


All Articles