|
As a novice, I have just played with the plug-in function of discuz, and I dare not enjoy the good things alone, so I will take it out and share the process of getting started with everyone. Now there are many plugin tutorials on discuz on the Internet are very simple tutorials, the reason may be that this thing is a commercial thing, in the spirit of sharing, today I made a tutorial by myself, a tutorial for discuz beginners. Very detailed introduction to how I got started. Problem 1.Discuz has no new plugins designed in the background! Solution: Add $_config['plugindeveloper'] = 2 at the bottom of configconfig_global.php; Just refresh the background app Question 2.How do I know at which point discuz has set the hook? After setting up 1 tool-> to clean the cache and then refresh the page, a lot of global_usernav_extra1 string-like things will appear, which is the anchor point, and it is also the point that the plugin can use. Okay, let's start making plugins: Back Office - > Apps - > design new plugins
After submitting, please enable it in the plugin management Then click Design It will enter as shown in the figure below
Next
Create a folder under source/plugin, the name of the folder should be the same as the identifier of the plugin you want to create. Then under the folder you created Create the files you need. As shown in the figure below, I have defined the test1 file embedded in the page in the module, and I need to create a new test1.class.php file in the plugin folder
Here's what to look out for.
test1.class.php the upper part of the Chinese is the introduction part of discuz, and the class name below must be the same as the name of the plugin. After that, write the function function in the class. It should be noted here that only if the name of the function is the same as the name displayed in the corresponding location outside will it run in the corresponding position in the corresponding page. Every time a new file is added or modified, try to refresh the cache file
After the corresponding page in the foreground is refreshed, the simple example we just did will appear.
It should be noted here that if you need to perform operations in a specified location, try not to use echo or var_dump when outputting the page, because this will output to the top, that is, the periphery of the web page. Using return will output at the specified place. It is worth noting that when writing a plugin, if you really want to output, follow step 1 and see if there is a page required for the foreground. At this point, the simple discuz plugin is developed. After clicking the export button, export the file and place it in the root directory of the current plugin folder, and you can directly publish it to others for normal use.
|