What is the purpose of beginBody() and endBody() ?

What is the purpose of beginBody() , endBody() and other similar functions called in the layout?

"Placeholders" to inject code:

http://www.yiiframework.com/doc-2.0/guide-structure-views.html

Look and read at “Creating Layouts”. ;)

That’s what the documentation says. :)

I guess my question was a bit vague. (Sorry for that).

What I want to know is how to use them?

say I want to insert some code at the beginning of the body only in a particular action. Do I have to override the beginBody() function? How?

Hi!

I think you have to trigger the events somehow.

Read about Events in Documentation.

Maybe that helps…

Sorry but I cant help much more or with a concrede example.

I’m not familar with YIIs events and handlers yet.

Just call them at the appropriate place.

No. Use beginBlock() / endBlock() for HTML or registerJs() for Javascript.The view component will takes care for the rest.