discuz添加新页面

原文链接:https://blog.csdn.net/YoperMan/article/details/83450897

假如我们想要增加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新增页面效果图(这不是默认主题)

性零糖

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值