2016-04-11 4 views
1

では動作しません。私は

<?=$t('Login Email Password')?> 
<?=$oneCode?> 
が含まれていonecode.mail.php

$body = $view->render(
    'template', 
    compact('users','oneCode','username'), 
    array(
     'controller' => 'users', 
     'template'=>'onecode', 
     'type' => 'mail', 
     'layout' => false 
    ) 
); 
$transport = Swift_MailTransport::newInstance(); 
$mailer = Swift_Mailer::newInstance($transport); 
$message = Swift_Message::newInstance(); 
$message->setSubject("Sign in password"); 
$message->setFrom(array(NOREPLY => 'Sign in password')); 
$message->setTo($email); 
$message->setBody($body,'text/html'); 
$mailer->send($message); 

から呼び出す

onecode.mail.php電子メールテンプレートを持っています

このリクエストを処理中にエラーが発生しました:

<b>Fatal error</b>: Function name must be a string in <b>app\resources 
\tmp\cache\templates 
\template_views_users_onecode.mail_0_1460392715_2266.php</b> on line <b>1</b><br/> 

すべての.html.phpファイルで完璧に動作しますが、.email.phpのテンプレートでは正しく動作しません。

何を行う必要がありますか?任意の提案、助けを感謝します。

+0

これは、$ T ''の値が関数名ではないことを意味。それが何であるかを見るにはonecode.mail.phpで 'echo $ t;'を試してください。どこで初期化しますか? – Kenney

+0

あなたの提案に従って試しましたが、エラーを変更しませんでした。私が.html.phpファイルで使用したときに初期化したことはありませんでした。だから、.mail.phpに対しても私は初期化しませんでした。 リチウムライブラリ\リチウム\ g11n \ Message.phpのいずれかで初期化されます。私はそのライブラリを呼び出すことを試みた 使用\リチウム\ gmm1 \メッセージ; ヘルプがありません。 –

+1

よろしくお願いします。私はリチウムライブラリに慣れていません。おそらく ''type' => 'mail''があなたの他のファイルと違うからです。たぶんprepend '<?php extract(Message :: aliases()); ?> 'あなたのonecode.mail.phpはそれを修正しますか? (それは[ここ](http://li3.me/docs/manual/common-tasks/globalization.md)で見つかりました)。とにかく、幸運! – Kenney

答えて

1

テンプレートに以下の行を追加してください:

<?php 
use lithium\g11n\Message; 
extract(Message::aliases()); 
?> 
<?=$t('Login Email Password')?> 

あなたが希望の言語で翻訳を取得することができるはずは

関連する問題