If you write a helper you sometimes want to access functions of another helper. Let’s say you want to use the link() function of the HtmlHelper in your own helper. First you have to define the helper you want to use in the $helpers array:
class TestHelper extends AppHelper {
var $helpers = array('Html');
}
You may expect that you could use the helper with $html->link(), but that leads to an “undefined variable” error (I blunder into this trap almost every time I use this functionality *g*). Instead you have to use $this->Html->link() as shown in the example:
class TestHelper extends AppHelper {
var $helpers = array('Html');
function getTheLink() {
return $this->Html->link('The link', '/');
}
}

Hey thanks so much, I was using it without $this!
@Kym: You are welcome!
Thanks for posting this. It was exactly what I was looking for as I wasn’t quite sure how to access a helper from within a helper.
@Dan: I’m glad this article was helpful for you, and happy baking!
Hi, thanks for the article!
Is it possible to request a helper inside a helper’s method? Same as you would do in a controller’s action instead of the entire controller?
function getTheLink() {
var $helpers[] = ‘Html’;
return $this->Html->link(‘The link’, ‘/’);
}
@enrique: Thanks for your comment!
You could use something like:
And depending on the helper you want to load you have to do some initializations.
However, if possible, I would avoid this approach and use what I described in the article ;-)