How To Make Custom Layout In Yii Framework
I am new to yii please tell me how to convert html template to yii framework give me some links for it to show some examples.
Solution 1:
I didn't get your question clearly, anyway if you want to make a new Yii layout, you need to do these steps in general:
- create a new php file in the protected/views/layouts dir, name it
new-temp.php for example. this page should print this var
<?php echo $content; ?>
create another php file in the same dir, name it new-temp-widget.php , this file should contain the following code :
<?php $this->beginContent('//layouts/new-temp'); ?><div id="content"><?php echo $content; ?></div><?php $this->endContent(); ?>
Finally, to use this template for a certain action, just write this code inside the action function
$this->layout = '//layouts/new-temp-widget';
OR if you want to apply this template for the whole controller, add var inside the controller:public $layout='//layouts/new-temp-widget';
for more details see this link : Working with Layouts in Yii
Post a Comment for "How To Make Custom Layout In Yii Framework"