扩展插件类 - 了解问题



我正在阅读扩展CMS。

我在理解一些细节方面有一些问题:

我需要创建一个插件类,例如 PollPlugin .

class PollPlugin(CMSPluginBase):
  model = PollPluginModel                 # Model where data about this plugin is saved
  name = _("Poll Plugin")                 # Name of the plugin
  render_template = "polls/plugin.html"   # template to render the plugin with
  def render(self, context, instance, placeholder):
      context.update({'instance':instance})
      return context
plugin_pool.register_plugin(PollPlugin) # register the plugin

我的问题:

  1. 在这种情况下instance是什么?
  2. 这两个插件类的目标是什么? PollPluginModelPollPlugin .
  3. ApphookPlugin之间的区别

任何答案都值得赞赏

Django-CMS插件可能有点棘手。

在这种情况下,instance将是PollPlugin的实例。

PollPlugin充当"连接"模型,将PollPluginModel的一个或多个实例与插件实例(PollPlugin(相关联,然后将其分配给页面上的占位符。

"apphook"是一个回调,它告诉Django-CMS它需要将视图的处理移交给应用程序模块中其他用户指定的URL模式。

"插件"是可以分配给占位符的模型。

最新更新