0

I want to use a custom and the core Html-Helper CakePHP 2.x within an email view generated through the CakePHP console. I am using CakeEmail the normal way but cannot get a grip on how to include helpers.

How do I use/add/include helpers in a view generated through the CakePHP console?

Adding public $helpers = array('Html'); to the shell doesn't work.

lorem monkey
  • 3,942
  • 3
  • 35
  • 49
  • **Clarification:** Seems like I misinterpreted the errors: the view wasn't missing the helpers, it was missing the base-url. If you find yourself in the situation were you think the Html-Helper doesn't work because the full-url is not returned, see here: http://stackoverflow.com/questions/11109785/creating-full-url-from-cakephp-2-1-2-console-shell – lorem monkey Sep 26 '12 at 13:26

3 Answers3

2

For CakePHP 1.3 I did it in a bit dirty way but it works

App::import("Core", "Controller");
App::import("Controller", "App");

class SomeShell extends Shell { 

  function startup() { 
    $this->Controller =& new AppController();

    ...
  }
}

and AppController uses helpers that I need in my email template. What do you think?

krzysu
  • 402
  • 4
  • 9
0

This should work in shell (but only in cakePHP below 2.x):

App::import('Core', 'Helper');

$html = new HtmlHelper();
Greg Motyl
  • 2,478
  • 17
  • 31
0

its documented here: http://book.cakephp.org/2.0/en/core-utility-libraries/email.html#sending-templated-emails

$email->helpers(array('Html', 'Custom', 'Text'));
mark
  • 21,691
  • 3
  • 49
  • 71