I just got in touch with DZ plug-in development and wrote a dummies graphic tutorial. one is to share it with beginners, and the other is to facilitate future memories. This article is suitable for the masses: I have some PHP development experience and want to quickly understand the basic steps of plug-in development through a simple and clear demo. Related Resources: dz official wikihttp: // dev.discuz.org/wiki/developer.e6.8f.92.e4.bb.b6.e. I just got in touch with DZ plug-in development and wrote a dummies graphic tutorial. one is to share it with beginners.
This article is suitable for the masses: I have some PHP development experience and want to quickly understand the basic steps of plug-in development through a simple and clear demo.
Related Resources: dz official wiki http: // dev.
Discuz. Org/wiki/#. E6.8F. 92. E4.BB. B6.E6.9C. BA. E5.88.B6
This demo function inserts a javascript code in the footer part of the template. this code can be an alert prompt or an advertisement.
Step 1:In the config \ config_global.php file, set $ _ config ['inindevelop'] = 1. if you do not have this variable, add one line. As the name suggests, when the plug-in development mode is enabled, some menus will appear in the background.
Step 2 Open DZ background-> Application-> design new plug-in, and fill in the information
Click submit to go to the settings page of this plug-in.
The background page is disabled first and will be used later.
Step 3Create the demo directory under source/plugin/and create the demo. class. php file in the demo Directory. the content is as follows:
If (! Defined ('in _ discuz ')){
Exit ('Access Denied ');
}
Class plugin_demo {
Function _ construct (){
}
Function global_footer (){
Return 'script "alert (" plug-in I'm coming ") script ';
}
}
Step 4Open DZ background-> Application-> plug-in and select "design" the demo we just created
On the Design page, click "module" and add a line, as shown in.
Click "submit" after adding"
Step 5Open DZ background-> Application-> plug-in, and "enable" our plug-in
Go to the front-end to open a page to see if the js script has been executed.
If not, go to the page and choose style management> update css cache and try again.
====================================== The following are advanced functions ======================
Function 1: Provides plug-ins with the ability to install and reverse installAdd install. php and uninstall. php under the plug-in Directory
If (! Defined ('in _ discuz ')){
Exit ('Access Denied ');
}
// Various installation operations
$ SQL = "show tables ";
Runquery ($ SQL );
// Or
DB: query ($ SQL );
$ Finish = TRUE;
?>
If (! Defined ('in _ discuz ')){
Exit ('Access Denied ');
}
// Various anti-installation operations to restore modifications during installation
$ SQL = "show tables ";
Runquery ($ SQL );
// Or
DB: query ($ SQL );
$ Finish = TRUE;
?>
Export an xml plug-in configuration file on the design page.
Put the exported xml file in the plug-in Directory
Now you can find that the installation/uninstall function is ready for use in the background.
Function 2: to automatically run a PHP code and embed a hook in a specific script when opening all pages If (! Defined ('in _ discuz ')){
Exit ('Access Denied ');
}
Class plugin_demo {
Function _ construct (){
}
// Global hook
Function common (){
Global $ _ G;
If ($ _ G ['uid']) {
// Add 1 point to experience
}
}
Function global_footer (){
Return 'script "alert (" plug-in I'm coming ") script ';
}
}
/**
* The register_top hook that runs only when the registration page under member. php is run
*
*/
Class plugin_demo_member extends plugin_demo {
Function register_top (){
Header ('Location: http://zc.qq.com/chs/index.html'); // guides the user to register the QQ number
Exit;
}
}
Function 3: enable the administrator to have more configurations in the background. (To be continued)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.