Templating with Yii


[*]How can one create a template with Yii?

Something similar to what Master Pages (in Prado, and ASP.NET 2.0+).

The idea of including snippets of code all over the place is not a smooth way of doing things.

[*]What are some of the best editors to use to develop yii with on a windows environment?


  1. As I know there is the layout,maybe not that you mean?

2.I use netbeans.org for php, it is free ,it has debuging, autocomplete (for Yii too if it is in include path) etc

I am working with the Blog demo. Basically, I’d like the entire demo to be a page in an existing website. The main problem I’m running into is displaying the Widgets on all the pages, much like the demo does. I don’t want to include these widgets in the layout of my website but just on the pages with the blog functionality. This would be similar to using nested master pages in ASP.NET which is what I’m most familiar with. I could change all the views for the Post scripts to get this effect but I’m wondering if there is a better way to accomplish this. Any ideas would be appreciated.

You can use a controller layout



Thanks for the reply. I had been looking at this but I’m not familiar enough with the framework to know how to use this. Do you know of an example or can give me some direction. I created a file I called layout.php and placed it in the view/post folder where all the other views for the blogs are. Inside the file I put the echo $content line I found in the application’s main layout file. So, I’m hoping that the views will first be included into MY layout then that would be included into the MAIN layout. If this is the case what is the code to set the layout property of my controller. I tried putting the following line at the top of the PostController class but this doesn’t work.

$this->layout = ‘layout.php’;

I may be going about this all wrong. Thanks again for your help.

Check if these links can help you out




Thanks for the suggestions. The first link is what I used and it was pretty simple to implement. Glad to see the support from other users with this framework. The more I learn about yii the more I like.