Chapter 4: Plug-in function functions

Release time:2017年08月08日 Author:Catfish CMS Reading volume:60729

In the previous chapter  we learned how to create a basic plug-in file, and know the basic  structure of the plug-in code, but also know where the plug-in  background code should be placed, Show information to the page, such as the announcement plug-in will be posted to the home page.


We use the bulletin plugin as an example, to see how to do in the home page shows the announcement.


Notice plug-in uses a function function "home_top" to output the announcement content to the home page. The code is as follows


    public function home_top(&$params)
    {
        //执行代码,输出到首页顶部
        $data = 'html代码';
        $this->add($params,'home_top',$data);//将公告内容追加到“home_top”
    }

Note: The red part must be the same!


The function code for the  function "home_top" is very simple. There are only two lines of code.  The first line puts the html code at the top of the home page into the $  data variable. The second line appends the contents of the announcement  to "home_top". Add the contents of the code is a  built-in function $ this-> add, this function has three parameters,  the first is the incoming system parameters, this parameter can be  copied as long as the second parameter is the function name, here is the  " Home_top "; The third parameter is the $ data variable, which stores the html code to be displayed.


Is not very  simple, as long as two lines of code can be written, in fact, you just  write html code on the line, the second line of code only need to copy  over.


The following functions provided by these systems can be used in this way to use


top:全站顶部
mid:全站中间
bottom:全站底部

home_top:首页顶部
home_mid:首页中间
home_bottom:首页底部

article_list_top:文章列表顶部
article_list_mid:文章列表中部
article_list_bottom:文章列表底部

article_top:文章顶部
article_mid:文章中部
article_bottom:文章底部

category_top:分类顶部
category_mid:分类中部
category_bottom:分类底部

page_top:页面顶部
page_mid:页面中部
page_bottom:页面底部

search_top:搜索顶部
search_mid:搜索中部
search_bottom:搜索底部

side_top:边栏顶部
side_mid:边栏中间
side_bottom:边栏底部

home_side_top:首页边栏顶部
home_side_mid:首页边栏中间
home_side_bottom:首页边栏底部

article_side_top:文章边栏顶部
article_side_mid:文章边栏中间
article_side_bottom:文章边栏底部

article_list_side_top:文章列表边栏顶部
article_list_side_mid:文章列表边栏中间
article_list_side_bottom:文章列表边栏底部

category_side_top:分类边栏顶部
category_side_mid:分类边栏中间
category_side_bottom:分类边栏底部

page_side_top:页面边栏顶部
page_side_mid:页面边栏中间
page_side_bottom:页面边栏底部

search_side_top:搜索边栏顶部
search_side_mid:搜索边栏中间
search_side_bottom:搜索边栏底部

comment_top:评论顶部
comment_mid:评论中间
comment_bottom:评论底部

Well, up to now, you can add the content you want to add anywhere on your site, and it's important to write code that's simple.


With these  functions, we also need some built-in functions to help us to work more  simple, just like $ this-> add this built-in function, we can copy as  long as you can use^_^


We'll learn about several built-in functions in the next chapter.


Go to the next chapter


Original article, reproduced please specify:Chapter 4: Plug-in function 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