Chapter 5: Plugins built-in functions

Release time:2016年11月13日 Author:Catfish CMS Reading volume:59491

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->add($params,'home_top',$data);

This has been learned in the previous chapter.


Next we will introduce a few useful built-in functions


1、"Set" function

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


$this->set(b,a);

Practical, for example, we have to open up a plug-in storage space, then you can use the following code


    public function open(&$params)
    {
        $this->set($this->plugin.'_announcement', '');
    }

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.


2、"Get" function

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


$this->get(b)

With the announcement plug-in example, is


$this->get($this->plugin.'_announcement')

3、"Delete" function

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)
    {
        $this->delete($this->plugin.'_announcement');
    }

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

Reward

I want to comment Sign in to post a comment


Latest release

bootstrap4如何实现div的水平居中以及垂直居中

bootstrap是一款十分流行的前端组件库,我们在制作模板的时候,使用bootstra...

鲶鱼CMS的页面设置中如何增减数量

Catfish(鲶鱼) CMS自版本4.9.6开始支持对页面设置可增减操作,我们来看一下...

网站二次开发的正确姿势

经常有用户朋友问我关于二次开发的问题,现在将这个问题比较详细地说一下。 过来问我关于二...

css样式处理超长的连续字母或数字,实现自动换行

有的伙伴建站以后,会在自己的网站分享一些链接,并且有些链接是超长的,由于链接一般都是由字...

绿色目录主题标准版 GreenD theme for Catfish...

主题名称:绿色目录主题标准版 GreenD theme for Catfish-CMS主...

MIME在form表单的文件上传中的应用

我们在制作文件上传时,通常会使用HTML标签“<input type="...

How to use the Catfish CMS system

Section 1: How to add articles

Management background is composed of five bl...

Section 2: to the article to add c...

In the previous section, we talked about how...

Section 3: Add a menu to your site

In the previous section we talked about how ...

Section 4: Page Setup

To the last section we have learned to use t...

Section 5: Change website name, LO...

By the end of the previous section, we have ...

Copyright © 2015 - 2019 Catfish(鲶鱼) CMS
Catfish(鲶鱼) CMS〖181836340〗 Catfish(鲶鱼) CMS 二群〖292598750〗

   I want to leave a message
Catfish(鲶鱼) CMS V 4.9.18