设为首页
收藏本站
首页
Portal
学院
BBS
立即注册
登录
搜索
本版
文章
帖子
搜索
热搜
活动
交友
discuz
学院
Discuz
Discuz 使用技巧
Discuz 增加独立页面
发新帖
返回列表
查看
1010
回复
0
Discuz 增加独立页面
复制链接
逆风天
逆风天
当前离线
16
主题
0
回帖
105
积分
超级版主
积分
105
发消息
发表于
2021-12-4 19:59:45
显示全部楼层
阅读模式
需求:
访问
https://www.nf12.com/windtalker.php?mod=index
或
https://www.nf12.com/windtalker.php
出现一个新的功能页面。
1、首先:在
网站根目录
下新建文件
windtalker.php
,内部代码如下:
<?php
define( 'APPTYPEID', 0 );
define( 'CURSCRIPT', 'windtalker' );
require './source/class/class_core.php';
$discuz = C::app();
//echo "<pre/>";
//print_r($discuz);
// 需要增加mod的话在 'index' 后面 添加 ,'newmod',像这样 'index', 'newmod'
$modarray = array( 'index' );
if ( !!isset( $_GET[ 'mod' ] ) && !in_array( $_GET[ 'mod' ], $modarray ) ) {
echo( 'mod is undefined!' );
}
// 直接访问 域名 + windtalker.php 或者 + windtalker.php?mod=index
$mod = isset( $_GET[ 'mod' ] ) ? $_GET[ 'mod' ] : 'index';
define( 'CURMODULE', $mod );
$discuz->init();
require libfile( 'function/windtalker' );
require libfile( 'class/windtalker' );
runhooks();
require DISCUZ_ROOT . './source/module/windtalker/wt_' . $mod . '.php';
?>
复制代码
2、然后:在
\source\class\
目录下新建文件
class_windtalker.php
,内部代码如下:
<?php
if ( !defined( 'IN_DISCUZ' ) ) {
exit( 'Access Denied' );
}
class index {
function __construct( $msg ) {
index( $msg );
}
function run() {
return "WelCome To WindTalker";
}
}
?>
复制代码
3、然后:在
\source\function\
目录下新建文件
function_windtalker.php
,内部代码如下:
<?php
if ( !defined( 'IN_DISCUZ' ) ) {
exit( 'Access Denied' );
}
function index( $msg ) {
// echo "new " . __FUNCTION__ . " model and runing in " . __FUNCTION__ . " model," . $msg;
}
?>
复制代码
4、然后:在
\source\module
目录下新增文件夹
windtalker
,新建文件
wt_index.php
,内部代码如下:
<?php
if ( !defined( 'IN_DISCUZ' ) ) {
exit( 'Access Denied' );
}
define( 'NOROBOT', TRUE );
//echo "hello world! I can laugh";
$c = new index( "Home" );
$info = $c->run();
include template( 'windtalker/index' );
?>
复制代码
5、然后:在
\template\你使用的模板目录\windtalker\
,新建文件
index.htm
,内部代码如下:
扩展思维:将common目录下的header.htm footer.htm复制到windtalker目录下 更改为{template windtalker/header} {template windtalker/footer}可实现新的模板结构,与原始的模板结构不冲突!如果不修改,就直接使用默认模板 default 目录下的文件
<!--{template common/header}-->
这里就是内容了!
{$info}
<!--{template common/footer}-->
复制代码
参考:
1、
https://blog.csdn.net/discuzmall/article/details/78360587
2、
https://blog.csdn.net/chenyoper/article/details/83450897
回复
举报
发新帖
返回列表
高级模式
您需要登录后才可以回帖
登录
立即注册
QQ
快速回复
返回列表