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.
时间: 01-10

Kooboo中怎么写Page Plugin -摘自官方文档的相关文章

别开心太早,Python 官方文档的翻译差远了

近几天,很多公众号发布了 Python 官方文档的消息.然而,一个特别奇怪的现象就发生了,让人啼笑皆非. Python 文档的中文翻译工作一直是“默默无闻”,几个月前,我还吐槽过这件事<再聊聊Python中文社区的翻译>,当时我们的进度是 10.3%,远远落后于日本和法国,甚至落后于巴西! 这次所谓的中文版,当然是未完成翻译的残品.刚查了下,整体进度是 19.7%. 翻译进度不足20% 有的公众号在发布消息的时候,说明了这不是官宣.不是正式发布版,还指出了中文版的访问地址是隐藏入口.这都是忠于

【AutoMapper官方文档】DTO与Domin Model相互转换(中)

写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) 持续更新中... 本篇目录: Custom Type Converters-自定义类型转换器 Custom Value Resolvers-自定义值解析器 Null Substitution-空值替换 Containers-IoC容器 后记 随着AutoMapper的学习深入,发现AutoMapper在对

swift官方文档中的函数闭包是怎么理解的?

官方文档中的16页: numbers.map({ (number: Int) -> Int in let result = 3 * number return result }) 不知道这个怎么用,更不知道它所说的要写个把奇数改成0的方法. swift官方文档中的函数闭包是怎么理解的?

Oracle 官方文档 结构说明(教你如何快速从官方文档中获取需要的知识)

这里以11g官方文档为例: 今天来说说怎么快速的从官方文档中得到自己需要的知识. 在线官方文档地址: http://tahiti.oracle.com/ 几乎囊括了 oracle各种产品的文档(oracle db12c的文档还没更新上来) 离线下载地址: www.oracle.com 这个不多说了 以11g官方网文档为例: Getting started 页面: 这里包括一些最基础的文档链接. Concept,里面包括了Oracle数据库里面的一些基本概念和原理.比如说数据库的逻辑结构.物理结构

反正你们写的都是没有即时演示的教程,我为什么不去看官方文档?

我就拿Vue举个栗子. Vue.js是什么,我想你多半知道,不然你也不会打开这篇文章. 这几天看到写Vue教程的文章突然多起来了.不过,就我所见,在这里发表的所有教程文章,都不支持即时演示,顶多有点儿自己画的图片之类的点缀一下.那么,请问您的文章和官网的交互式教程相比有什么优势?高级技巧或者独创的tricks就算了,那些写基础教程的作者们,您的目标读者全是不看官方文档,吃不下饼干非得您给嚼碎了再喂的那种蠢驴吗? 但是! 看完这篇文章,你至少可以在你的教程里加入一些简单的Vue交互(或者别的骚东西

tensorflow官方文档中的sub 和mul中的函数已经在API中改名了

在照着tensorflow 官方文档和极客学院中tensorflow中文文档学习tensorflow时,遇到下面的两个问题: 1)AttributeError: module 'tensorflow' has no attribute 'sub' #进入一个交互式Tensorflow会话 import tensorflow as tf sess = tf.InteractiveSession() x = tf.Variable([1.0,2.0]) a = tf.constant([3.0,3.

Android官方文档之App Resources(中)

本文将继续介绍App Resources中的资源类型(Animation.Color State List.String.Style). 如果需要了解Android中的资源规范,您可以访问我翻译的这篇官方文档:<Android官方文档之App Resources(上)>. 如需访问官方原文,您可以点击这个链接:<Resource Types>. 在下一篇文章中(Android官方文档之App Resources(下)),将介绍App Resources中其余的资源类型(Layout

swift官方文档中的switch中case let x where x.hasSuffix(&quot;pepper&quot;)是什么意思?

在官方文档中,看到这句.但不明白什么意思. let vegetable = "red pepper" switch vegetable { case "celery": let vegetableComment = "Add some raisins and make ants on a log" case "cocumber", "watercress": let vegetableComment = &

有关于OpenStack的Rocky版官方文档部署中的一些错误

OpenStack-Rocky版本的错误错误1:在装包时包下载失败,在确定系统源没有问题之后,发现Ping不通百度.最后,添加了DNS解决的,说明没有添加DNS(/etc/resolv.conf). 错误2:作为admin用户,请求身份验证令牌时发生错误,应为端口错误,在配置的时候,使用的是5000,下面命令中测试使用的是35357,所以错了.[[email protected] ~]# openstack --os-auth-url http://controller:35357/v3 \ -