discuz怎么添加一个页面

版权声明:本文为博主原创文章,未经博主允许不得转载-陈永鹏。 https://blog.csdn.net/YoperMan/article/details/83450897

PHP技术交流群:180460365、320205320

今天要修改discuz的一点东西,想添加一个页面。作为一个老牌的PHP论坛系统。一直以来都听过他的名声。

但是真没做过啊。

于是花了点时间看了下。

假如我们想要增加discuz一个页面是http://sex.linglingtang.com/test.php?mod=my

首先:建 \test.php(入口)

即在根目录新建一个php文件,就叫 test.php ,这个是入口文件;

然后:建 \source\class\class_test.php(类)

即在\source\class 新建模块类文件 class_test.php ,在里面添加my类;

然后:建 \source\function\function_test.php(方法)

即在\source\function,定义不同的mod方法;

然后:建 \source\module\test\test_my.php(后端控制器)

即在\source\module 新增 test文件夹,在test文件夹新增文件 test_模块名.php;

然后:建 \template\default\test\my.htm(前端模板)

即在默认主题/theme/default/ 新建test文件夹,在test文件夹里新建模板文件my.htm , 也就是theme/default/test/my.htm;

代码如下:

\test.php

<?php
define('APPTYPEID', 0);
define('CURSCRIPT', 'test');
 
require './source/class/class_core.php';
$discuz = C::app();
$modarray = array('my');
 
if(!isset($_GET['mod']) && !in_array($_GET['mod'],$modarray)){
    die('mod is undefined!');
}
 
$mod = isset($_GET['mod']) ? $_GET['mod']:'my';
define('CURMODULE', $mod);
$discuz->init();
 
require libfile('function/test');
require libfile('class/test');
runhooks();
require DISCUZ_ROOT.'./source/module/test/test_'.$mod.'.php';

\source\class\class_test.php

<?php
/**
 * Yoper test
 */
if(!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
class my{
    function __construct($msg){
        my($msg);
    }
    function  run(){
        return "www.linlingtang.com";
    }
}
?>

\source\function\function_test.php

<?php
/**
 * Yoper add
 */
function my($msg){
    echo "~ my ~";
}

\source\module\test\test_my.php

<?php
if(!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
define('NOROBOT', TRUE);

$c = new my("hello,my");
$time = $c->run();
include template('test/my');

\template\default\test\my.htm

<!--{template common/header}-->
<div class="my">
<br><br><br><br><br>
    <center>my页面</center>
<br><br><br><br>
</div>
<!--{template common/footer}-->

discuz新增页面效果图(这不是默认主题)

性零糖

广告时间~~~~~~~

现在的公众号,都是女博情感啊、鸡汤啊。动不动就几十万阅读。

我们辛辛苦苦码代码一个月。还不如人家一篇鸡汤文赚得多。

码农转型中,欢迎关注我时不时瞎吐槽的个人公众号——零零糖。

有趣的个人公众号

陈永鹏的CSDN技术博客

陈永鹏博客园

PHP技术交流群:180460365、320205320

BIPIMI

零零糖

猜你喜欢

转载自blog.csdn.net/YoperMan/article/details/83450897
今日推荐