portlet的问题:不能放在crontroller的vieww中么???

我建了一个portlet,内容是一行字,我放到了默认的controller的view index.php中。但是这样的话效果有问题,而且查看源代码发现整个index.php的输出竟然先于main.php部分的html代码。

而只能将portlet放到coloumn中,就如同blog的用例一样。

我的理解是portlert是一个重复性很强的,区块代码,它应该能在我想它出现的任何位置出现,而不影响页面布局,或者代码的顺序。

请回复我,不胜感激。项目着急用。

I have built a portlet, the content is just only one word ‘go’, and I put the default in the controller’s view index.php. But the effect of this is the case in question, and view the source code found in the output even before the index.php part in main.php html code.

weather the portlet can be only used in coloumn the same use cases as the blog.

In my optionion ,that portlert is a highly repetitive, block codes, I think it should be able to appear anywhere it occurs, without affecting the page layout, or code sequences.

Please reply to me, much appreciated. Hurry with the project.

render一个view+layout,的确是view先被render的。这个你可以查看一下CController::render()的实现。

portlet/widget的render是根据它们所在的view来决定次序的。

正常情况下,在view里的portlet/widget是没法插入到layout的html里的,除非你使用了注册的办法来跳出正常流程。

一种办法是在base controller class里声明widgets属性,并在layout里显示每一个在widgets里注册的widget(就是一个配置数组)。

在view里,你根据需要注册对应的widget。

这种做法比较类似Gii里产生的CRUD代码里的menu实现。

谢谢qiang,还是你及时。呵呵。

可以考虑把这个过程更简化一点。我觉得一个区域性重复利用的代码,如果能高效的话,还是很不错的。