Twitter bootstrap 动态导航取决于Zend Framework 2中的登录状态
我在顶部的导航栏中有一个小的登录表单,带有输入字段、电子邮件、密码和登录按钮(见下图)。 如何根据用户的登录状态替换它?如果用户已登录,则应显示一个下拉列表,供其注销等操作(参见图2)Twitter bootstrap 动态导航取决于Zend Framework 2中的登录状态,twitter-bootstrap,zend-framework2,zfcuser,Twitter Bootstrap,Zend Framework2,Zfcuser,我在顶部的导航栏中有一个小的登录表单,带有输入字段、电子邮件、密码和登录按钮(见下图)。 如何根据用户的登录状态替换它?如果用户已登录,则应显示一个下拉列表,供其注销等操作(参见图2) 我正在使用ZF2、zfc用户和Twitter引导程序3。 登录小部件的我的导航条形码: ` $form=$this->zfcUserLoginWidget(数组('render'=>false))->getVariable('loginForm'); $form->setAttribute('action',$
我正在使用ZF2、zfc用户和Twitter引导程序3。
登录小部件的我的导航条形码: `
$form=$this->zfcUserLoginWidget(数组('render'=>false))->getVariable('loginForm');
$form->setAttribute('action',$this->url('zfcuser/login');
$form->setAttribute('method','post');
$form->setAttribute('class','navbar-form-navbar-right-form-inline');
echo$this->form()->openTag($form);
echo$this->formElementErrors($form->get('identity'))?>
好的,我在打瞌睡时想到了解决办法:
<!-- Test if the User is connected -->
<?php if(!$this->zfcUserIdentity()): ?>
<!-- display the login form -->
<?php echo $this->zfcUserLoginWidget(array('redirect'=>'application')); ?>
<?php else: ?>
<!-- display the 'display name' of the user -->
<?php echo $this->zfcUserIdentity()->getDisplayname(); ?>
<?php endif?>
我只是把我的代码复制粘贴到部分中,它就工作了
<!-- Test if the User is connected -->
<?php if(!$this->zfcUserIdentity()): ?>
<!-- display the login form -->
<?php echo $this->zfcUserLoginWidget(array('redirect'=>'application')); ?>
<?php else: ?>
<!-- display the 'display name' of the user -->
<?php echo $this->zfcUserIdentity()->getDisplayname(); ?>
<?php endif?>