我在elements / navigation.ctp中,在导航栏中我提出了一个条件:
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell">
<?php
//$location_status=$this->data['Location']['status'];
//$location= $this->Location->find("status = '$location_status'");
//$this->Session->write('Location', $location['Location']);
//$this->loadModel("Location");
if($this->Location->read('Location.status')!==0):
echo '<span class="glyphicon glyphicon-exclamation-sign" style="color:red;">
</span>';
?>
<?php endif;?>
</i>
<b class="caret">
</b>
</a>
<ul class="dropdown-menu alert-dropdown">
<li>
<a href="#"><span class="label label-danger">Notificaion</span></a>
</li>
<li class="divider"></li>
<li>
<a href="#">View All</a>
</li>
</ul>
</li>
答案 0 :(得分:0)
我有解决方案,我只是在我的视图中导入模型,这是代码:
App::import('Model', 'Location');
$this->Location = new Location();
if ($this->Location->field('status')=='0'):
echo '<span class="glyphicon glyphicon-exclamation-sign" style="color:red;">
</span>';