私の問題は次のとおりです。
ログイン ビューの代わりにログイン要素を使用したいと考えています。そのため、default.ctp でログインを使用できます... ユーザーがすべてのページからログインできるようにしたいと考えています。これは一種のドロップダウン メニューである必要があります。
コントローラーに要素を使用して、ビューではなく要素データを取得するように指示するにはどうすればよいですか?
私の LoginsController ログイン機能:
function login()
{
$this->set('headline','Melden Sie sich an...');
if($this->request->is('post'))
{
if($this->Auth->login())
{
//$this->redirect($this->Auth->redirect);
$this->redirect(array('action' => 'index'));
$this->Session->setFlash('Ihr Login war erfolgreich!');
}
else
{
// $this->Session->setFlash('Ihre Email/Passwort ist falsch!' . ' ' . $this->request->data['Login']['email'] . ' ' . $this->request->data['Login']['password']);
$this->Session->setFlash('Ihre Email/Passwort ist falsch!');
}
}
$this->render('logins/login');
}
私のビュー/要素:
<aside id="left">
<div class="whitebox einloggen">
<div class="rahmen">
<h2>Login</h2>
<div class="inside">
<?php echo $this->Html->para(null,'Sind Sie bereits als Nutzer registriert?');
echo $this->Form->create('Login', array('action' => 'login'));
echo $this->Form->input('email', array ('label' => false, 'type'=>'text','class'=>'text', 'value'=>'E-Mail','id'=>'LoginEmail', 'onfocus'=>"resetinput(this);", 'onBlur'=>"fillinput(this);"));
echo $this->Form->input('password', array ('label' => false, 'type'=>'text','class'=>'text', 'value'=>'Passwort','id'=>'LoginPassword', 'onfocus'=>"resetinputpw(this);", 'onBlur'=>"fillinput(this);"));
echo $this->Form->end(array('label'=>'Einloggen','class' => 'button long','type' => 'submit','name'=>'submit'));
echo $this->Html->para('forgetpw', $this->Html->link('Passwort vergessen?', array('controller' => 'login', 'action' => 'forgotpwd'), array('label' => false, 'class' => 'forgetpw', 'title'=>'Passwort vergessen')));
echo $this->Html->link('', array('controller' => 'login', 'action' => 'fblogin'), array('class' => 'facebook-button', 'title'=>'Mit Facebook einloggen'));
?>
</div>
</div>
</div>
次のように default.ctp の要素を呼び出します。
<?php echo $this->element('/logins/login'); ?>
ログインビューがないことについて常に不平を言っています...
これが良い習慣でない場合は、別の方法を教えてください;-)
私の悪い英語でごめんなさい、そしてありがとう!