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>

  

参看上面例子中的三元表达式加以运用哦

上一篇:Jenkins入门系列之——03PDF文档下载


下一篇:轻松学习java可重入锁(ReentrantLock)的实现原理