CakePHP – View Events

CakePHP - View Events

There are several cakephp view callbacks/events that we can use with View Events in CakePHP. These events are helpful to perform several tasks before something happens or after something happens. The following is a list of callbacks that can be used with CakePHP view Events āˆ’

Sr.NoEvent Function & Description
1Helper::beforeRender(Event $event,$viewFile)
TheĀ beforeRenderĀ method is called after the controllerā€™s beforeRender method but before the controller rendersĀ viewĀ andĀ layout. This receives the file being rendered as an argument.
2Helper::beforeRenderFile(Event $event, $viewFile)
This method is called before each view file is rendered. This includesĀ elements, views, parent viewsĀ andĀ layouts.
3Helper::afterRenderFile(Event $event, $viewFile, $content)
This method is called after each View file is rendered. This includesĀ elements, views, parent viewsĀ andĀ layouts. A callback can modify and returnĀ $contentĀ to change how the rendered content will be displayed in the browser.
4Helper::afterRender(Event $event, $viewFile)
This method is called after the view has been rendered, but before the layout rendering has started.
5Helper::beforeLayout(Event $event, $layoutFile)
This method is called before the layout rendering starts. This receives the layout filename as an argument.
6Helper::afterLayout(Event $event, $layoutFile)
This method is called after the layout rendering is complete. This receives the layout filename as an argument.

Next Topic : Click Here

Leave a Reply