1. 程式人生 > >thinkphp3.2.3模板渲染支援三元表示式

thinkphp3.2.3模板渲染支援三元表示式

thinkphp3.2.3模板渲染支援三元表示式

{$status?'正常':'錯誤'}
{$info['status']?$info['msg']:$info['error']}

注意:三元運算子中暫時不支援點語法。

如下:

           <div class="modal hide fade" id='myModal'>
                      <div class="modal-dialog">
                        <div class="modal-content">
                          <div class="modal-header" style='background-color: #0ca5ec'>
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="color:white;opacity:0.6;">×</button>
                            <h3 style="color:white">某某某融資網</h3>
                          </div>
                          <div class="modal-body">
                            <p style="text-align:center;color:red;font-size:18px;line-height:20px;padding:0 0 4px 0;">{$popAcData['a_popStatus']?$popAcData['a_Title']:$popHuigu['n_Title']}
</p> <img src="{$popAcData['a_popStatus']?$popAcData['a_Photo']:$popHuigu['n_Image']}" alt="{$popAcData['a_popStatus']?$popAcData['a_Title']:$popHuigu['n_Title']}"> </div> <div class="modal-footer"> <a href="javascript:void(0);" class="btn">關閉</a> <a href="javascript:void(0);" class="btn btn-primary">{$popAcData['a_popStatus']?檢視活動詳情:檢視活動回顧}
</a> </div> </div> </div> </div>

  

<script type="text/javascript" src='__PUBLIC__/popUp/popUp-js/jquery-3.1.0.min.js'></script>
<script type="text/javascript" src='__PUBLIC__/popUp/popUp-js/bootstrap.min.js'></script>
<script type="text/javascript" src='__PUBLIC__/popUp/popUp-js/popUp.js'></script>
<script type="text/javascript">
 var $j = jQuery.noConflict();
 $j(function(){
     //活動開始顯示彈窗 活動沒開始讀活動回顧
    $j('#myModal').modal('show');

  var btn = $j('.btn');
  btn.eq(0).click(function(){
	 $j('#myModal').modal('hide');
  });
  btn.eq(1).click(function(){
	 $j('#myModal').modal('hide');
	 window.location.href={$popAcData['a_popStatus']}?"{:U('/Activity/detail',array('a_Id'=>$popAcData['a_Id']))}":"{:U('/News/newsContent',array('n_Id'=>$popHuigu['n_Id']))}";
  })
; }) </script>

  

參看上面例子中的三元表示式加以運用哦