在Plone 5中,您可以通过注册模板插件在TinyMCE编辑器中使用html模板。模板是生活在文件系统中的html片段,它们也在plone ressource注册表中注册。这是一个例子:
<?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请求模板。在这种情况下,安全性被考虑在内。但它相当昂贵。有没有办法直接访问模板(plone资源)而不绕过安全性?
答案 0 :(得分:0)
您可以通过网址直接访问模板。 类似的东西:
portal.restrictedTraverse('++theme++mytheme/tinymce-templates/tmpl2.html')
这同样适用于页面模板。