Has anyone managed to integrate HTML5 Boilerplate in the YII PHP Framework (specifically the folder structure and build process)?
Check my Yii BoilerPlate and Bootstrap Integration
https://github.com/drumaddict/YiiApp
Boilerplate recommends using the @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 Yii::app()->clientScript Model to register the file. Yii allows you to register script files as needed, per controller or per view. Therefor your http requests can be minimal. I would suggest registering the required scripts/css in the main layout and add other scripts as they are needed with the
Yii::app()->clientScript->registerScriptFile();
Yii is based on the MVC model. The V is for view. The view foldes contain the html elements your model and controller will adjust based on data types. Inside the view folder Yii uses the layout folder to define layouts.
$this->layout = 'main';
That line will look for:
Protected -> views -> layout -> main.php
The layout folder should contain main, _htmlHead, _header and _footer. The renderPartial will be used for render the different layout parts. It's like a php include for HTML. The second param of $this->render or $this->renderPartial is used to pass data to the view. For example nav data:
$this->renderPartial('_footer', array('nav'=>array('/link/'=>'Link Name')));
In the _htmlHead register the needed elements using the Yii::app()->clientScript. If you want to use a different version of jQuery then use the ScriptMap model, don't register jQuery twice. Yii's coreScript, validation and paging 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've used the config.php file in Yii to set an assetsLocaion parameter. If I move my assets it won't break the site.
Yii::app()->clientScript->registerScriptFile(Yii::app()->param->assetsLocation.'/js/example.js');
The basic layout of the boilerplate will be defined in the layout/main.php. Check out the theme documentation: http://www.yiiframework.com/doc/guide/1.1/en/topics.theming
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With