Skip to content

Instantly share code, notes, and snippets.

@ibndawood
Created March 21, 2013 08:58
Show Gist options
  • Save ibndawood/5211668 to your computer and use it in GitHub Desktop.
Save ibndawood/5211668 to your computer and use it in GitHub Desktop.
Accessing a View function in a helper. The current view object is stored in the _View attribute of the Helper class is extended by AppHelper and all other Helpers in CakePHP. $this->assign is a view function and if you want to use this view function in a Helper this is how we use it :
<?php
App::uses('AppHelper', 'View/Helper');
class MyHelper extends AppHelper{
public function assignTitle($pageTitle){
return $this->_View->assign('pageTitle', $pageTitle);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment