Getting started with Discuz plug-in development

Source: Internet
Author: User
As a newbie, we are also just playing with the discuz plug-in function. if you don't want to enjoy anything, let's share the Getting started process with everyone. Many plug-in tutorials on discuz are very simple on the Internet, probably because they are commercialized. in the spirit of sharing, I made a tutorial myself today, getting started with discuz

As a newbie, it is just getting started.DiscuzPlug-in functions, good things do not dare to be exclusive, let's share the process of getting started.
Many plug-in tutorials on discuz are very simple on the Internet, probably because they are commercialized. in the spirit of sharing, I made a tutorial myself today, discuz beginner's tutorial.
I will introduce in detail how to get started.
Problem 1. no new plug-in is designed in the discuz background!
Solution: Add $ _ config ['inindevelop'] = 2 at the bottom of config \ config_global.php; refresh the background application.
Question 2. how do I know that discuz has set hooks at those points?
After setting 1, the tool-> clear the cache and refresh the page. many things similar to stringglobal_usernav_extra1 appear. this is the anchpoint and can be used by the plug-in.
Now let's start the plug-in:
Background-> Application-> design new plug-ins

After submission, enable it in plug-in management.

Then click design

As shown in

Next

Create a folder under source/plugin. the folder name must be the same as the identifier of the plug-in to be created.

Then, create the desired file under the created folder. If I have defined the test1 class file embedded in the page in the module, you need to create a new file test1.class. php in the plug-in folder to love you.

Note the following.

The above part of the file in test1.class. php is the introduction part of discuz, and the following class name must be consistent with the plug-in name.

Then write the function in the class. Note that only when the function name is consistent with the name displayed at the external location will it run in the corresponding location on the corresponding page.

Refresh the cached files whenever possible when a new file is added or modified.

After refreshing the corresponding page on the front-end, a simple example is displayed.

Note that if you need to perform operations at the specified position, do not use echo or var_dump for output during page output, because it will output to the top, that is, the outer part of the webpage. Return is output in the specified place.

It is worth noting that when writing a plug-in, if you really want to output it, follow the first step to see if there is any page on the front-end. At this point, the simple discuz plug-in has been developed. Click the export button and place the exported file in the root directory of the current plug-in folder and publish it directly to others for normal use.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.