public function beforeRender() { // Modify some data before sending it to the view $data = $this->viewVars['data']; $data['new_param'] = 'New Value'; $this->set(compact('data')); }
public function beforeRender(Event $event) { parent::beforeRender($event); // Modify the view template $this->viewBuilder()->setTemplate('new_template'); }Here, we're modifying the view template to use a different template file called "new_template". Package/Library: The above examples were part of PHP frameworks that come with their own implemented plugin package libraries.