Home  >  Article  >  Backend Development  >  The use of Onethink1.1 hooks and plug-ins!

The use of Onethink1.1 hooks and plug-ins!

WBOY
WBOYOriginal
2016-08-08 09:29:191003browse

Please download Onethink from Baidu. Installation only takes a few seconds.

Experts (omitted), just for novices like me who need to understand.

I mainly talk about the use of onethink plug-in, because it is helpful for our rapid development, so I will record it, and I also hope it can help friends who want to know more.

Let’s start with the hook, First look at the background interface below:

step1. Select "Add"

step2. Fill in the hook name as required (the hook name is unique), then click "OK", and it will prompt that the creation is successful.

As shown in the picture:

The hook is created.

Next:

step4. If there is a hook, call it. Find the template that needs to be called and add the following statement: {:hook('BannerImageSlide')}

Note: It’s a hook, not a hook;

Next:

step5. Click "Quick Create" in "Plug-in Management"

Next:

step6. Select or fill in as needed and click "OK".

Next:

step7. Click to install.

Return to the file and view the generated directories and files:

The ImageSlide directory and two files config.php and ImageSlideAddon.class.php are generated under ./Addons/

How to see the effect of our plug-in under your own hook?

Find your hook method in the class and try printing it.

If the calling place prints the echo information in the plug-in just now, it means it can be called. If it is not called, you need to double-check to see if the correct location is not called.

How to write the plug-in?

Next, write plug-in template:

step9. The content in the question mark is the variable assigned to this template, which can be represented by placeholders first.

It is worth mentioning that writing plug-in templates is no different from writing html pages. You can also introduce css, js, images and other resources required by the plug-in into the page.

Assign variables in the plugin class:

The configuration here is not very convenient to explain, I will explain it later.

After configuring, you can use the "Settings" operation of the plug-in

Before configuration:

After adding the plug-in configuration information:

step10. If the "Settings" operation does not appear, please "uninstall" first and then install. Click "Settings";

Next:

step11. Fill in the value to be displayed

step13. Click "OK".

Next:

step15. Find the plug-in class file, obtain the configuration information, and assign variables to the template file content.html

The effect is as above, the next step is natural, get the variable value in the plug-in template.

Next:

The final effect is as shown in the picture:

Note that if the value in the red box is not obtained, it is very likely that you have not set the value in the plugin "Settings".

Hope it will be helpful to friends who need it. The next step is to use a plug-in to create an image scrolling effect.

The above introduces the use of Onethink1.1 hooks and plug-ins! , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

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