Systemnews1Action.class.php
public function news(){
session_start();
if (isset($_SESSION['user']) && !empty($_SESSION['user'])) {
$user = $_SESSION['user'];
$this->assign("user",$user);
}
$news = D('System_news1')->where(array('id'=>$_GET['id']))->find();
$this->assign('news',$news);
$comments = D('Comments')->join('pigcms_user on pigcms_comments.uid=pigcms_user.uid')->where(array('nid'=>$_GET['id']))->order("pigcms_comments.id desc")->limit(5)->select();
$this->assign("comments",$comments);
$this->display();
}
news.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<link rel="stylesheet" href="http://localhost/tpl/wap/static/css/jquery.dialogbox.css">
<script type="text/javascript" src="http://localhost/tpl/wap/static/js/jquery.min.js"></script>
<style>
<script type="text/javascript">
function pl(){
var uid = $("#uid").val();
if(uid == ''){
$('#type-dialogBox2').dialogBox({
title: "登录提示", //标题内容,如果不设置,则连同关闭按钮(不论设置显示与否)都不显示标题
width: 260,
height: 150,
hasMask: true,
hasClose: true,
confirmValue: "是", //确定按钮文字内容
confirm: function(){alert(1)}, //点击确定后回调函数
cancelValue: "否", //取消按钮文字内容
hasBtn: true,
content: '登录失败,重新登录!',
function($btn){
if($btn == "确定") {
$('#type-dialogBox2').dialogbox({type:"normal",title:"Result",message:"You pressed: Ok"});
}
}
});
return false;
}
}
</script>
</head>
<body>
<div id="type-dialogBox2"></div>
<div>
<input type="hidden" id="uid" value="{pigcms{$user.uid}"/>
<input type="button" id="retry_ignore_abort2" onClick="pl()" class="btn" value="评论"/>
<br />
</div>
<script src="http://localhost/tpl/wap/static/js/jquery.dialogBox.js"></script>
</body>
</html>
dialogBox插件下载地址:
http://download.csdn.net/download/ougexingfuba/9883153效果如下: