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: Set $ _ config [plugindeveloper] 1 in the config \ config_global.php file. if you do not have this variable, add a row. As the name suggests, after the plug-in development mode is enabled
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 3
Create 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 4
Open 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 5
Open 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 install
Add install. php and uninstall. php under the plug-in Directory
If (! Defined ('in _ discuz ')){
Exit ('Access Denied ');
}
$ SQL = "show tables ";
Runquery ($ SQL );
DB: query ($ SQL );
$ Finish = TRUE;
?>
If (! Defined ('in _ discuz ')){
Exit ('Access Denied ');
}
$ SQL = "show tables ";
Runquery ($ SQL );
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 (){
}
Function common (){
Global $ _ G;
If ($ _ G ['uid']) {
}
}
Function global_footer (){
Return 'script "alert (" plug-in I'm coming ") script ';
}
}
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;
}
}