1.jtbc.push.js放至/console/common/assets/js
2.push.inc.php放至/console/common/incfiles
3.在/news/template/manage.jtbc中查找
<name><![CDATA[list]]></name>節(jié)點,注意是[list]節(jié)點,在第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>
如果你在其他地方調(diào)用新聞標(biāo)題列表,比如首頁,就加上一句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");
?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~