In Rails it’s easy:
View has:
<% content_for :sidebar do %>
... sidebar HTML ...
<% end %>
Layout has:
<%= yield :sidebar %>
Can I do same in Yii?
UPDATE: How can use both dynamic header, content and footer in main.php layout?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can define
public $sidebarin your base Controller component. Then you can assign to$this->sidebarin your views or controllers and retrieve$this->sidebarin your layouts. You should also look intorenderPartial()which can be used in layouts, controllers, and views to render partial HTML content (content without layout). e.g.$this->renderPartial('/some/view')