我正在尝试为我的三种用户帐户类型构建一个基本的标题下拉导航,但它们有不同的选项,具体取决于帐户类型。我的代码抛出错误。代码如下:
<div class="btn-group pull-right">
<?php if ($this->logged_in):
$is_a = ($this->logged_in_usertype == App_Model_Users::TYPE_A);
$is_b = ($this->logged_in_usertype == App_Model_Users::TYPE_B);
$is_c = ($this->logged_in_usertype == App_Model_Users::TYPE_C);
?>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-user"></i> <?php echo $this->logged_in_nickname;?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<?php if ($is_b):?>
<li><a href="/profile/<?php echo $this->logged_in_slug;?>/one">Page Option One</a></li>
<li class="divider"></li>
<li><a href="/profile/<?php echo $this->logged_in_slug;?>/two">Page Option Two</a></li>
<li class="divider"></li>
<li><a href="/profile/<?php echo $this->logged_in_slug;?>/page/three">Page Option 3</a></li>
<li class="divider"></li>
<li><a href="/profile/<?php echo $this->logged_in_slug;?>/four">Page Option 4</a></li>
<li class="divider"></li>
<?php if ($is_a):?>
<li><a href="/profile">Account-type 2 Profile</a></li>
<?php endif;?>
<?php endif;?>
<li><a href="/member">Account Settings</a></li>
<li class="divider"></li>
<li><a href="/logout" id="logout-link">Sign Out</a></li>
</ul>
<?php else:?>
<a class="btn" href="/login">
<i class="icon-user"></i> Register / Login
</a>
<?php endif;?>
</div>
我认为我的问题是(if is_a)的第二个 if 语句......但我不确定 - 我对 php 很陌生。有人可以帮助我用正确的方法来构造这个 if 语句,尽可能少地改变代码吗?