在 Rails 中很容易:
View 有:
<% content_for :sidebar do %>
... sidebar HTML ...
<% end %>
布局有:
<%= yield :sidebar %>
我可以在 Yii 中做同样的事情吗?
更新:如何在 main.php 布局中同时使用动态页眉、内容和页脚?
最佳答案
View 有:
<?php $this->beginClip('sidebar'); ?>
Hi there!
<?php $this->endClip(); ?>
布局有:
<?= $this->clips['sidebar'] ?>
更多信息请查看 CController 文档。
但平心而论,这是做侧边栏的错误方法。
关于ruby-on-rails - Yii:如何在 View 中定义局部布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8116032/