Kooboo中怎么写Page Plugin -摘自官方文档
Page plugin development
Page plugin is an add-on to Kooboo CMS, and is responsible for making data source available for page access. It is similar to module, but while module contains user interface for both the backend and the frontend site, page plugin does not contain any UI. Some of the uses of page plugin are:
- Get data from remote service for users on the Page.
- Submit a Page to add content OR send an email.
- Other requests.
It is ok to write the data access code on the layout OR views, but it is not recommended in the MVC pattern. A better solution for such cases is to use the Page Plug-in to write the logic code into a custom assembly, then upload it into Kooboo CMS and use it in Pages or Views.
It is easy to develop a Page Plug-in. We have released the VS Project Template to help developers create Page Plug-in projects more eaisly. The "PagePluginSample.cs" in the project template is the same Page Plug-in. The brief of developing a Page Plug-in is implementing the interface of "IPagePlugin".
public interface IPagePlugin { string Description { get; } ActionResult Execute(Page_Context pageContext, PagePositionContext positionContext);
ActionResult HttpGet(Page_Context context, PagePositionContext positionContext); ActionResult HttpPost(Page_Context context, PagePositionContext positionContext);
} NOTE: The HttpGet and HttpPost are new methods in Kooboo CMS 4.0. They will be executed corresponding to the HttpMethod(Get and Post).
Developing Page Plug-ins
- Download Kooboo.CMS.PluginTemplate.vsi.
- Double click the Kooboo.CMS.PluginTemplate.vsi to install the project templates into Visual Studio.
- Create a Page plug-in project using the project template under "Visual C# -> Web".
- Remove these three files: "AssemblyInitializer.cs","CustomContentEventSubscriber.cs","CustomSiteEventsSubscriber.cs".
- Rename the "PagePluginSample" as your own plug-in name.
- Write the logic code in the "Execute" method.
Using Page Plug-ins
- Upload assembly of the Page Plug-in into Kooboo CMS Site. NOTE: Please also upload the dependency assemblies of the plugin assembly, otherwise you will encounter an "assembly not found" message at runtime.

- Add the plugin into the Page or View. NOTE: The execution sequence at runtime will be the same for you to add the plugin into either Page or View.

The execution sequence of Page Plug-in
All the Page Plug-ins are added both in the Page and Views(The views added in the page, which are not using RenderView.) will be invoked in the controller. The sequence flow for the Page execution will be: Kooboo CMS Request Flow.jpg

The picture shows the Page Plug-ins will be invoked foremost the controller action.
- When the "Execute" method returns a NOT-Null ActionResult value, the controller action will be returned without running the following code. For example: The plug-in want to return a JsonResult, JavascriptResult, ContentResult,FileResult etc...
- When the "Execute" method returns a Null value, the controller action will continue to run the following and render the Page html. In this case, the developer can store the custom data into ViewData, which can be used in the Layout and Views.
pageViewContext.ControllerContext.Controller.ViewBag.PluginData = "Hello plug-in";
By default, the page plugin will be invoked in all types of http requests, but you can filter by the http method to limit it to run only on specific types of requests. e.g:
if (pageViewContext.ControllerContext.RequestContext.HttpContext.Request.HttpMethod.ToUpper() =="POST") { }
Built-in Page Plug-ins
There are three types of Page Plug-ins built into Kooboo CMS.
- AddTextContentPlugin, used to add content using the submission values.
- UpdateTextContentPlugin, used to update text content using the submission values.
- DeleteTextContentPlugin, used to delete text content.
Kooboo中怎么写Page Plugin -摘自官方文档的更多相关文章
- [Qt] 文本文件读写, 摘自官方文档
Reading Files Directly The following example reads a text file line by line: QFile file("in.txt ...
- 别开心太早,Python 官方文档的翻译差远了
近几天,很多公众号发布了 Python 官方文档的消息.然而,一个特别奇怪的现象就发生了,让人啼笑皆非. Python 文档的中文翻译工作一直是“默默无闻”,几个月前,我还吐槽过这件事<再聊聊P ...
- 教大家怎么看monaco-editor的官方文档
最近业务中有用到浏览器在线编辑器,用的是monaco-editor,官网文档只在首页介绍了npm安装方式. 但其实还有另外一种<script>的引入方式,但是这种方式体现在API文档中,由 ...
- 微信小程序官方文档中表单组建button部分有关function(type)中type的个人理解
官方文档关于button组件的简介 xml页面挺容易理解,但js部分起初对整体写的形式都不太理解,随着逐渐阅读代码基本理解了 xml页面代码: <button type="defaul ...
- 【AutoMapper官方文档】DTO与Domin Model相互转换(中)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- swift官方文档中的函数闭包是怎么理解的?
官方文档中的16页: numbers.map({ (number: Int) -> Int in let result = * number return result }) 不知道这个怎么用, ...
- java中的方法引用(method reference)官方文档总结
2017/7/5 转载写明出处:http://www.cnblogs.com/daren-lin/p/java-method-reference.html 今天要说的是java中的一项新特性,方法引用 ...
- 《SpringCloudDubbo开发日记》(一)Nacos连官方文档都没写好
背景 现在的微服务框架一般分dubbo和springcloud两套服务治理体系,dubbo是基于zookeeper为注册中心,springcloud是基于eureka作为注册中心. 但是现在eurek ...
- 从官方文档中探索MySQL分页的几种方式及分页优化
概览 相比于Oracle,SQL Server 等数据库,MySQL分页的方式简单得多了,官方自带了分页语法 limit 语句: select * from test_t LIMIT {[offset ...
随机推荐
- SQL的多表操作
多表更新: 假定我们有两张表,一张表为Product表存放产品信息,其中有产品价格列Price:另外一张表是ProductPrice表,我们要将ProductPrice表中的价格字段Price更新为P ...
- 开发设计模式(九)门面模式(Facade Pattern)
什么是门面模式? 门面模式要求一个子系统的外部与其内部的通信必须通过一个统一的门面(Facade)对象进行.门面模式提供一个高层次的接口,使得子系统更易于使用. 大家都写过纸质的信件吧,比如给女朋友写 ...
- 成为Java GC专家(3)—如何优化Java垃圾回收机制
为什么需要优化GC 或者说的更确切一些,对于基于Java的服务,是否有必要优化GC?应该说,对于所有的基于Java的服务,并不总是需要进行GC优化,但前提是所运行的基于Java的系统,包含了如下参数或 ...
- 创建第一个UI
创建一个2D UI 制作UI时,首先要创建UI的"根".在Unity顶部NGUI菜单中选择Create,然后选择2D UI. 创建完成后,在Scene窗口中,NGUI自动生成了一个 ...
- 【实用技巧】文件MD5修改方法
方法一 利用md5修改器 更新日志:2011-10-6 22:00修正对于路径中存在空格修改无效的bug2011-10-6 20:17更新:1.回归简约界面2.直接拖拽即可捕获地址3.一键修改文件 ...
- ECSHOP安装或使用中提示Strict Standards: Non-static method cls_image:
随着ECSHOP的不断发展,越来越多的人成为了ECSHOP的忠实粉丝.由于每个人的服务器环境和配置都不完全相同,所以ECSHOP也接二连三的爆出了各种各样的错误信息.相信不少新手朋友在ECSHOP安装 ...
- linux挂载详解
一 .linux文件结构 文件结构是文件存放在磁盘等存贮设备上的组织方法.主要体现在对文件和目录的组织上.目录提供了管理文件的一个方便而有效的途径. linux使用标准的目录结构,在安装的时候,安装程 ...
- BZOJ 4005 [JLOI 2015] 骗我呢
首先,我们可以得到:每一行的数都是互不相同的,所以每一行都会有且仅有一个在 $[0, m]$ 的数没有出现. 我们可以考虑设 $Dp[i][j]$ 为处理完倒数 $i$ 行,倒数第 $i$ 行缺的数字 ...
- [转载]常用Web Service汇总(天气预报、时刻表等)
下面总结了一些常用的Web Service,是平时乱逛时收集的,希望对大家有用. ============================================ 天气预报Web Servic ...
- HDU2167+状态压缩DP
状态压缩dp 详见代码 /* 状态压缩dp dp[ i ][ j ]:第i行j状态的最大和 dp[i][j] = max( dp[i-1][k]+sum[i][j] ); 题意:给定一个N*N的方格, ...