In the previous chapter, we learned about some of the plug-in functions that allow us to output new content anywhere in the site. In this chapter, we'll learn about the built-in functions of several systems to help make things easier.
In the last chapter we have exposed a built-in function "add", which is called in the plugin class: $ this-> add (). The built-in function is to achieve the output of the html code.
A practical example is：
This has been learned in the previous chapter.
Next we will introduce a few useful built-in functions：
Set function is stored as a key-value pair, for example, we want to store the variable a in the storage space of the key b, then we can call the set function：
Practical, for example, we have to open up a plug-in storage space, then you can use the following code：
public function open(&$params)
We opened up a key named "$ this->plugin. '_ announcement'" storage space, the initial space is empty.
The suggested key names are in the form of "plugin name_variables", as in the example above for "$ this-> plugin. '_ announcement'", $ this-> plugin is the plugin name we defined.
Get function is used to take out the contents of the storage, only one parameter, is the key name. Then the above example, we now want to take out the key storage space b content, we can do：
With the announcement plug-in example, is：
Delete function is used to delete the key storage space. When you are sure you do not need to use the development of the key space, you can delete it, so as not to create too much garbage. This is normally used when closing plug-ins. For example, when you close the announcement plug-in, we use the function to clear the announcement of storage space：
public function close(&$params)
Use is very simple, on a parameter, the parameter is "set" function to set the key name.
With these four built-in functions, we can design a lot of plug-in effects you want to achieve.
You can find the bulletin plugin file, and then refer to the code.
Original article, reproduced please specify：Chapter 5: Plugins built-in functions | Catfish(鲶鱼) CMS
主题名称：绿色目录主题标准版 GreenD theme for Catfish-CMS主...
Management background is composed of five bl...
In the previous section, we talked about how...
In the previous section we talked about how ...
To the last section we have learned to use t...
By the end of the previous section, we have ...