1

在 Plone 5 中,您可以通过注册模板插件在 TinyMCE 编辑器中使用 html 模板。模板是存在于文件系统中的 html 片段,它们也在 plone 资源注册表中注册。这是一个例子:

<?xml version="1.0"?>
<registry>
  <record name="plone.templates" interface="Products.CMFPlone.interfaces.controlpanel.ITinyMCESchema" field="templates">
    <field type="plone.registry.field.Text">
      <default></default>
      <description xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="help_tinymce_templates">
        Enter the list of templates in json format http://www.tinymce.com/wiki.php/Plugin:template
      </description>
      <required>False</required>
      <title xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="label_tinymce_templates">Templates</title>
    </field>
    <value>[
      {"title": "Template 1", "url": "++theme++mytheme/tinymce-templates/tmpl1.html"},
      {"title": "Template 2", "url": "++theme++mytheme/tinymce-templates/tmpl2.html"}
        ]</value>
  </record>
  <record name="plone.custom_plugins" interface="Products.CMFPlone.interfaces.controlpanel.ITinyMCESchema" field="custom_plugins">
      <field type="plone.registry.field.List">
        <default/>
        <description xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="">
          Enter a list of custom plugins which will be loaded in the editor. Format is pluginname|location, one per line.
        </description>
        <required>False</required>
        <title xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="">Custom plugins</title>
        <value_type type="plone.registry.field.TextLine"/>
      </field>
      <value>
        <element>template|+plone+static/components/tinymce-builded/js/tinymce/plugins/template</element>
      </value>
  </record>
</registry>

我的问题是:如何从 python 代码或 TAL 访问模板?第一种可能性是从文件系统中读取文件。但是随后将通过安全层。二是通过http请求模板。在这种情况下,安全性被考虑在内。但它相当昂贵。有没有办法在不绕过安全性的情况下直接访问模板(克隆资源)?

4

1 回答 1

0

您可以通过 url 直接访问模板。就像是:

portal.restrictedTraverse('++theme++mytheme/tinymce-templates/tmpl2.html')

这同样适用于页面模板。

于 2017-06-27T14:15:14.550 回答