-
Notifications
You must be signed in to change notification settings - Fork 142
Helpers
Mark edited this page Jan 25, 2014
·
3 revisions
My AppHelper usually inherits the Tools MyHelper:
App::uses('MyHelper', 'Tools.View/Helper');
class AppHelper extends MyHelper {
}
Furthermore, you can use aliasing to use any of the Tools plugin helpers as if they were normal App helpers:
App::uses('MyController', 'Tools.Controller');
class AppController extends MyController {
public $helpers = array(
'Session',
'Html' => array('className' => 'Tools.HtmlExt'),
'Form' => array('className' => 'Tools.FormExt'),
'Tools.Common',
'Tools.Format',
'Tools.Datetime',
'Tools.Numeric',
'AssetCompress.AssetCompress',
...
);
}
Be careful NOT to set those aliased helpers in other controllers' or plugin controllers' $helpers properties then again without the verbose alias definition. This would effectively reverse the aliasing again. It's best to always only specify the additional helpers in extending controllers:
class PostsController extends AppController {
public $helpers = array('SomeAdditional', 'PluginName.SomeOther');
}