thinkphp3.2.3模板渲染支持三元表达式
程序员文章站
2022-06-16 20:42:23
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>
参看上面例子中的三元表达式加以运用哦