discuzx2.5添加頁面

來源:互聯網
上載者:User

標籤: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添加頁面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.