Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP 2: Html Helper in Email Template
    text
    copied!<p>I'm having a tough time trying to figure out why I can't use $this->Html->url in the templates for my emails for CakePHP 2.0. The Helpers array is empty in the views. Is this by design or am I missing something?</p> <p>The docs and migration guide don't mention anything around this.</p> <p>The trace looks like:</p> <pre><code>include - APP/View/Emails/html/admin/users_recover.ctp, line 1 View::_render() - CORE/Cake/View/View.php, line 598 View::render() - CORE/Cake/View/View.php, line 365 CakeEmail::_render() - CORE/Cake/Network/Email/CakeEmail.php, line 1300 CakeEmail::send() - CORE/Cake/Network/Email/CakeEmail.php, line 933 UsersController::_sendRecoverEmail() - APP/Controller/UsersController.php, line 186 UsersController::admin_login() - APP/Controller/UsersController.php, line 101 ReflectionMethod::invokeArgs() - [internal], line ?? Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 476 Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 106 Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 88 [main] - APP/webroot/index.php, line 96 </code></pre> <p>Here is the function that I have sending the recovery email:</p> <pre><code>private function _sendRecoverEmail($email, $recoverKey) { App::uses('CakeEmail', 'Network/Email'); $cakeEmail = new CakeEmail(); $cakeEmail-&gt;config('default'); $cakeEmail-&gt;to($email); $cakeEmail-&gt;subject('Recover Your '. Configure::read('Site.title') . ' Account'); $cakeEmail-&gt;template('admin/users_recover'); $cakeEmail-&gt;viewVars(array( 'recoverKey' =&gt; $recoverKey, )); try { $cakeEmail-&gt;send(); } catch (Exception $e) { trigger_error("ERROR in UsersController::sendRecoverEmail: couldn't send email to: {$email}."); return false; } return true; } </code></pre> <p>And finally, the view:</p> <pre><code>&lt;p&gt;Have you been having difficulty getting into your &lt;?php echo Configure::read('Site.title'); ?&gt; account?&lt;/p&gt; &lt;?php $url = $this-&gt;Html-&gt;url(array('action' =&gt; 'recover', 'controller' =&gt; 'users', $recoveryKey), true); ?&gt; &lt;p&gt;If this is correct, &lt;a href="&lt;?php echo $url; ?&gt;"&gt;click here to recover your access and create a new password.&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Your password will remain the same if you ignore it.&lt;/p&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload