2017-04-12 4 views
1

Plone 5에서는 템플릿 플러그인을 등록하여 TinyMCE 편집기에서 html 템플릿을 사용할 수 있습니다. 템플릿은 파일 시스템에있는 html 스 니펫이며 plone ressource 레지스트리에도 등록되어 있습니다. 다음은 예입니다.파이썬 코드 또는 TAL로 TinyMCE 템플릿에 액세스하는 방법은 무엇입니까?

<?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> 

질문 : 어떻게 파이썬 코드 또는 TAL에서 템플릿에 액세스 할 수 있습니까? 첫 번째 가능성은 파일 시스템에서 파일을 읽는 것입니다. 하지만 보안 계층은 지나갈 것입니다. 두 번째는 http로 템플릿을 요청하는 것입니다. 이 경우 안전이 고려됩니다. 하지만 다소 비쌉니다. 보안을 우회하지 않고 템플릿 (plone 리소스)에 직접 액세스 할 수 있습니까?

+0

여기 포럼에 귀하의 질문에 대한 링크를 게시 했음에도 불구하고 우리 포럼, community.plone.org에 게시하여 답변을 얻는 것이 더 나을 것입니다. –

답변

0

URL을 통해 직접 템플릿에 액세스 할 수 있습니다. 같은 뭔가 :

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

같은 페이지 템플릿에 적용됩니다.