如何读取字段值Cakephp 2 / Javascript

时间:2015-03-15 20:28:21

标签: javascript jquery cakephp

我在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它显示一个通知图标,当它为1时它什么都没显示,但问题我认为我已经把假代码

1 个答案:

答案 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>';