標籤:discuz style http io ar color os sp for
http://www.php230.com/discuz-add-a-new-page.html
下面就簡單介紹一下discuz添加頁面的方法:
1、在根目錄添加photo.php檔案,代碼如下
1、在根目錄添加photo.php檔案,代碼如下
<?php/** * 修改【圖說天下】版本文章發布時間 * Created by PhpStorm. * User: sumiaowen * Date: 14-1-20 * Time: 下午3:52 * To change this template use File | Settings | File Templates. */define(‘CURSCRIPT‘, ‘photo‘);require_once ‘./source/class/class_core.php‘;$discuz = & discuz_core::instance();$discuz->init();include template("diy:photo/modify");include ‘./photo/class_photo.php‘;$photo = new photo();$photo->updateDateline();
2、添加模板檔案,./template/default/photo/modify.htm(相對根目錄)
<!DOCTYPE html><html><head><title>修改【圖說天下】版本文章發布時間</title><meta charset="GBK"></head><body><h2>【圖說天下】版塊文章發布時間修改</h2><div style="margin-left: 20px;"><form action="photo.php" method="post">文章ID:<input type="text" name="tid" value=""/><input type="submit" name="submit" value="修改" style="cursor: pointer"/></form><p style="font-size: 13px;">註:</p><p style="font-size: 13px;">1、只能修改【圖說天下】版塊下的文章</p><p style="font-size: 13px;">2、文章修改時間預設為目前時間.</p></div></body></html>
注意:discuz靜態檔案的尾碼名為htm
3、添加處理類,./photo/class_photo.php(相對根目錄),代碼如下:
<?php/** * 修改【圖說天下】版本文章發布時間 * Created by PhpStorm. * User: sumiaowen * Date: 14-1-20 * Time: 下午4:30 * To change this template use File | Settings | File Templates. */if(!defined(‘IN_DISCUZ‘)){exit(‘Access Denied‘);}class photo{public function updateDateline(){global $_G;if(isset($_POST[‘submit‘])){//擷取文章tid$tid = (int)$_G[‘gp_tid‘];//擷取文章資訊$query = DB::query("select * from " . DB::table(‘forum_thread‘) . " where tid={$tid} and fid=393");$result = DB::fetch($query);//判斷文章存在if($result){//更新文章時間$ctime = $_SERVER[‘REQUEST_TIME‘];$sql = "update com_forum_thread as t,com_forum_post as pset t.dateline={$ctime},p.dateline={$ctime}where t.tid={$tid} and p.tid={$tid} and p.`first`=1";if(DB::query($sql)){echo "<span style=‘color:blue;‘>SUCCESS:</span>Successfully modified post {$tid}. New Times is " . date(‘Y-m-d H:i:s‘, $ctime);}else{echo "<span style=‘color:Red;‘>ERROR:Failure modified. Please try again later.</span>";}}else{echo "<span style=‘color:Red;‘>ERROR:The tid of {$tid} is not existence!</span>";}}}}
提示:這裡沒有對操作許可權進行限制。為了安全,建議還是要添加操作許可權控制。
通過上面3步就可以完成新頁面添加了,我們可以通過URL:http://www.test.com/photo.php進行新頁面訪問了。
如果新頁面是靜態頁面,那麼第三步就沒有必要了。
discuzx2.5添加頁面