beforeRender and afterRender
Posted 01 April 2013 - 01:08 PM
I wouldn't be able to do that by using the beforeAction or afterAction events. Would I?
Posted 01 April 2013 - 01:23 PM
There's also a difference; There might be actions that doesn't render things in the common way and in these cases you might not want your beforeAction/afterAction to apply, hence being able to use beforeRender/afterRender in these cases might be good.
I'm thinking there are enough use cases to preserve these events after all.
Posted 03 April 2013 - 05:52 AM
I wonder if buffering output could interfere with nested output buffering, e.g. I think Yii clips use output buffering. May be more Yii methods use output buffering during the render phase, not sure...
Sorry, I don't understand what you mean here. Could you explain please?
Posted 15 April 2013 - 03:48 AM
I was thinking about using beforeRender or afterRender to insert some extra content to larger group of my views (not all of them, but a significant number, among different controllers). But this path turned out to be wrong. I think behaviors will be better.
Posted 10 May 2014 - 12:51 PM
This happens mainly because in the current Yii, you need to register most of the JS/CSS files from within the layout file(it has no use to do it in controller when you use themes because various themes use various assets), then, if you register new files from within the controller action will screw up the order of the scripts being rendered, and i found that the solution to avoid this issue is to register the scripts in afterRender().
Another solution for my problem would be to create a general behavior that would read a config file from the theme and will register the assets found in that file, but it seems overkill for this.
Anyway, bottom line, do not remove these methods, they are useful.