1.jtbc.push.js放至/console/common/assets/js
2.push.inc.php放至/console/common/incfiles
3.在/news/template/manage.jtbc中查找
<name><![CDATA[list]]></name>节点,注意是[list]节点,在第3个<default><![CDATA[<nav genre="{$=$genre}"><span>{$-account-nav}{$=universal\category::getCategoryNavByID($getPara('genre'), '{$-lang}', '{$-nav-category}')}</span></nav>
后添加<script type="text/javascript" src="{$=$assetspath}/js/jtbc.push.js"></script>
如果你在其他地方调用新闻标题列表,比如首页,就加上一句SQL
比如这个<jtbc $function="transfer" $parameter="genre=news;type=new;limit=6;osql= and n_time<now()">
还有这个{$=transfer('genre=news;category=3;type=new;limit=24;osql= and n_time<now();baseurl=./;tpl=news_list')}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jtbc.push.js代码如下
$(document).ready(function(){
var s = jQueryAjaxPost("2");
});
function jQueryAjaxPost(pushData) {
var return_data = "";
$.ajax({
type: "POST",
dataType: "json",
url: "common/incfiles/push.inc.php",
data: pushData,
async: false,
success: function(data, status) {
if(status == "success") {
return_data = data;
} else {
return_data = "error";
}
}
});
return return_data;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
push.inc.php代码如下
<?php
include_once ("../../../common/incfiles/const.php");
$r = array();
@$db = mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if (mysqli_connect_errno()) {
echo json_encode("sorry,the conntect had some wrongs");
exit ;
}
$read = "select n_id,n_time,n_timing from jtbc_news where n_id=(select max(n_id) from jtbc_news)";
$result = mysqli_query($db, $read);
$rownumber = mysqli_num_rows($result);
for ($i = 0; $i < $rownumber; $i++) {
$row = mysqli_fetch_assoc($result);
array_push($r, $row['n_id'], $row['n_time'],$row['n_timing']);
}
if(($r[2]!=null)&&($r[1]!=$r[2])){
$up="update jtbc_news set n_time='$r[2]' where n_id='$r[0]'";
mysqli_query($db, $up);
}
mysqli_close($db);
echo json_encode("ok");
?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~