我的问题是以下内容:蛋糕PHP登录元素
我想使用登录元素,而不是登录视图。 所以我可以在我的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.thtml中的元素:
<?php echo $this->element('/logins/login'); ?>
它总是comp laining失踪登录视图...
如果这个心不是一个很好的做法,请教我,否则;-)
对不起我的英文不好,并感谢!
仔细检查该文件中的应用程序存在/浏览/元/登录/注册.ctp,并且它是一个ctp扩展名,并确保您删除语句中的开头“/”。 $这 - >元件( '登录/登录'); –