search
HomeBackend DevelopmentPHP Tutorialdestoon复制新模块的方法_php实例

在destoon的实际使用过程中我们往往需要根据情况建立一些系统没有的模块,这时候就需要复制已有的模块来根据已有模块建立新的模块,具体操作方法如下:

首先选择一个我们需要的模块(因为系统默认文章和信息模块是可以复制的,在这里我们只研究非默认的模块怎么复制),我选择的是模块名称是品牌,目录名是brand,模块ID是13,你也可以根据你的需要选择要复制的模块。

第一步,复制根目录下的brand这个文件夹,粘贴然后重命名,这里我们用rename命名作为示范。于是你的根目录下多了一个名称为rename的文件夹,我们打开这个文件夹,找到config.inc.php这个文件,打开后里面是这样写的

<&#63;php
$moduleid = 13;
&#63;>

把这里的13改成一个你现在模块ID里没有的数字,我们用88代替它作为示范。

第二步,找到根目录下/module这个文件夹打开,复制里面的brand文件夹,粘贴后重命名为rename,打开这个新文件夹内的admin/config.inc.php这个文件,里面的文件是这样的(为方便理解,此处增加了注释)

<&#63;php
defined(‘IN_DESTOON') or exit(‘Access Denied');
$MCFG['module'] = ‘brand';//这里改为 ‘rename';
$MCFG['name'] = ‘品牌';//这里改为你的新模块名比如: ‘新模块';
$MCFG['author'] = ‘Destoon.COM';
$MCFG['homepage'] = ‘www.destoon.com';
$MCFG['copy'] = false;//这里改为true;
$MCFG['uninstall'] = true;
$MCFG['moduleid'] = 13;//这里改为88;
$RT = array();
$RT['file']['index'] = ‘品牌管理';
$RT['file']['html'] = ‘更新网页';
$RT['action']['index']['add'] = ‘添加品牌';
$RT['action']['index']['edit'] = ‘修改品牌';
$RT['action']['index']['delete'] = ‘删除品牌';
$RT['action']['index']['check'] = ‘审核品牌';
$RT['action']['index']['expire'] = ‘过期品牌';
$RT['action']['index']['reject'] = ‘未通过品牌';
$RT['action']['index']['recycle'] = ‘回收站';
$RT['action']['index']['move'] = ‘移动品牌';
$RT['action']['index']['level'] = ‘品牌级别';
$CT = true;
&#63;>

将这里的品牌,全部替换为你的新模块名比如:'新模块',并根据注释做相应修改后保存,然后打开同级目录内的html.inc.php这个文件在大概65和66行找到

if($update) {
require MD_ROOT.'/brand.class.php';
$do = new brand($moduleid);
}

把两个brand替换为rename后保存,再打开同级目录内的index.inc.php这个文件,在大概在第三行找到

require MD_ROOT.'/brand.class.php';
$do = new brand($moduleid);

同样把这两个brand替换为rename后保存,OK,找到上级目录(根目录/module/rename)的my.inc.php这个文件,用编辑器的替换功能把所有brand替换为rename后保存,再打开同级目录下的brand.class.php这个文件,同样用编辑器的替换功能把所有brand替换为rename后另存为(注意是另存为)rename.class.php。

第三步,找到你的模板路径(默认为根目录/template/default)复制brand文件夹粘贴后重命名为rename,再打开同级目录下的member文件夹找到my_brand.htm这个文件,复制粘贴后重命名为my_rename.htm。

做完以上三步,我们的复制模块之路的代码方面就基本完成了,接下来就是复制数据库了,找到数据库中destoon_brand和destoon_brand_data这两张表,复制后重命名为destoon_rename和destoon_rename_data,(如果数据库在运行中,可能需要暂停后执行以上操作)

OK,完成之后登录后台,在 我的面板-》模块管理 里面选择添加模块,然后填入模块名称如: “新模块”,在所属模型这个下拉选项中你会发现多出来一个名为“新模块”的选项,选中它,在安装目录里填上rename,点确定。然后去功能模块中看,是否已经多出来一个名为 “新模块”的功能模块?如果出现,说明你刚刚的操作没有问题,恭喜你模块已经添加完成了。但是你沉浸在喜悦之中急切的想在新模块中添加数据的时候发现页面是空白的,这是为什么呢?原因就在于在模块设置里面有个信息排序方式,在这里随便选择一个,顺便把下面的列表或搜索主字段也填填吧,填完之后点确定,再去试一试添加是不是就可以使用了?

实际使用过程中还会遇到一个问题,就是添加的这个模块在会员中心使用的时候提示没有权限,请升级,去看了后台会员组权限发布信息的权限已经做了勾选,为什么还提示权限不够呢?解决方法是,找到根目录/module/member/admin/template/group_edit.tpl.php这个文件,在大概762行找到如下代码

</tr>
<tr>
<td class=”tl”>发布下载总数限制</td>
<td>
<input type=”text” name=”setting[down_limit]” size=”5″ value=”<&#63;php echo $down_limit;&#63;>”/>
</td>
</tr>
<tr>
<td class=”tl”>免费发布新模块数量</td>
<td>
<input type=”text” name=”setting[down_free_limit]” size=”5″ value=”<&#63;php echo $down_free_limit;&#63;>”/>
</td>
</tr>

改为:

</tr>
<tr>
<td class=”tl”>发布新模块总数限制</td>
<td>
<input type=”text” name=”setting[rename_limit]” size=”5″ value=”<&#63;php echo $rename_limit;&#63;>”/>
</td>
</tr>
<tr>
<td class=”tl”>免费发布下载数量</td>
<td>
<input type=”text” name=”setting[rename_free_limit]” size=”5″ value=”<&#63;php echo $rename_free_limit;&#63;>”/>
</td>
</tr>

复制这段改过的代码放在前面找到的那段代码的下面,保存后刷新,再去设置里面查看一下,最下面多出来两个需要填写的输入框,填进相关数字,点确定。OK,到这里会员就可以使用新模块了。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

How to Register and Use Laravel Service ProvidersHow to Register and Use Laravel Service ProvidersMar 07, 2025 am 01:18 AM

Laravel's service container and service providers are fundamental to its architecture. This article explores service containers, details service provider creation, registration, and demonstrates practical usage with examples. We'll begin with an ove

Customizing/Extending Frameworks: How to add custom functionality.Customizing/Extending Frameworks: How to add custom functionality.Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.