2012-03-19 63 views
1

如何在`structure provider:xxx的頁面模板中動態查找提供程序?動態TAL提供程序:表達式

考慮下面的非工作示例

<div class="portlet-manager-row" tal:repeat="portletId python:range(1,5)"> 
    <div class="porlet-well_manager"> 
     <h2 i18n:translate="portlet-well-a">Portlet Well <b tal:content="portletId" /></h2> 
     <tal:manager define="managerId string:ColophonPortlets${portletId}"> 
      <span tal:replace="structure provider:managerId" /> 
     </tal:manager> 
    </div> 
</div> 

的部分供應商:失敗,因爲供應商:假定輸入總是直接字符串提供者的名稱似乎並沒有接受變量。

+0

我不明白... – Jihaisse 2012-03-19 08:05:14

+0

編輯該問題突出顯示有問題的部分。 – 2012-03-19 08:25:10

+0

也許你可以使用「path」TAL命令,不知道你是否可以使用裏面的「provider:」。 – 2012-03-19 10:32:44

回答

1

傳說提供商表達子類字符串表達式,所以你應該能夠做到這一點:

<div class="portlet-manager-row" tal:repeat="portletId python:range(1,5)"> 
    <div class="porlet-well_manager"> 
     <h2 i18n:translate="portlet-well-a">Portlet Well <b tal:content="portletId" /></h2> 

     <span tal:replace="structure provider:ColophonPortlets$portletId" /> 
    </div> 
</div> 

注意字符串表達式是多餘的,我感動並簡化了$portletId變量代換;對於更復雜的字符串插值,請使用${expression}語法(例如${request/providername})。