discuz怎么添加一个页面

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

 

零零糖

 

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值