Templates 如何创建一个plone视图来插入内容项的其他较小视图?
我认为这应该很简单。我有一个folderish TTW灵巧性内容项(一个下拉框),其中包含folderish TTW灵巧性项(建议)。每个提案都包含TTW敏捷性评审,我想对这些评审中的字段进行总结 我可以轻松创建一个视图,通过对FolderList视图的简单修改,为任何提案生成如下所示的表:Templates 如何创建一个plone视图来插入内容项的其他较小视图?,templates,view,plone,dexterity,Templates,View,Plone,Dexterity,我认为这应该很简单。我有一个folderish TTW灵巧性内容项(一个下拉框),其中包含folderish TTW灵巧性项(建议)。每个提案都包含TTW敏捷性评审,我想对这些评审中的字段进行总结 我可以轻松创建一个视图,通过对FolderList视图的简单修改,为任何提案生成如下所示的表: [review1 link] [criterion_1 value] [criterion-2 value]... [review2 link] [criterion_1 value] [crite
[review1 link] [criterion_1 value] [criterion-2 value]...
[review2 link] [criterion_1 value] [criterion-2 value]...
.
.
[proposal1 link] [column I would like to insert the above table in for this proposal]
[proposal2 link] [column I would like to insert the above table in for this proposal]
.
.
我还可以通过修改FolderList视图为drop box生成工作表视图:
[review1 link] [criterion_1 value] [criterion-2 value]...
[review2 link] [criterion_1 value] [criterion-2 value]...
.
.
[proposal1 link] [column I would like to insert the above table in for this proposal]
[proposal2 link] [column I would like to insert the above table in for this proposal]
.
.
我的问题是我不知道如何将第一个表插入到第二个表第二列的单元格中。我试过两件事:
。这甚至部分是正确的方法吗?它不会给出任何错误,但也不会在我的页面中插入任何内容谢谢。此解决方案大致基于kuel提供的示例:和--多谢各位 我发现最容易创建和调试的方法是:
<table class="review_summary listing">
<tbody><tr class="column_labels"><th>Review</th><th>Scholarly Merit</th><th>Benefits to Student</th><th>Clarity</th><th>Sum</th></tr>
<metal:listingmacro define-macro="listing">
<tal:foldercontents define="contentFilter contentFilter|request/contentFilter|nothing;
contentFilter python:contentFilter and dict(contentFilter) or {};
I kept all the standard definitions from the original template.
I have just removed them for brevity.
plone_view context/@@plone;">
The following tal:sum is where I did some math on my data. If you are
not manipulating the data this would not be needed. Note that I am only
looking at the first character of the choice field.
<tal:sum define="c1_list python:[int(temp.getObject().restrictedTraverse('criterion_1')[0])
for temp in batch if temp.portal_type=='ug_small_grants_review'];
c1_length python: test(len(c1_list)<1,-1,len(c1_list));
c2_list python:[int(temp.getObject().restrictedTraverse('criterion_2')[0])
for temp in batch if temp.portal_type=='ug_small_grants_review'];
c2_length python: test(len(c2_list)<1,-1,len(c2_list));
c1_avg python: round(float(sum(c1_list))/c1_length,2);
c2_avg python: round(float(sum(c2_list))/c2_length,2);
avg_sum python: c1_avg+c2_avg;
">
<tal:listing condition="batch">
<dl metal:define-slot="entries">
<tal:entry tal:repeat="item batch" metal:define-macro="entries">
<tal:block tal:define="item_url item/getURL|item/absolute_url;
item_id item/getId|item/id;
Again, this is the standard define from the folder_listing.pt
but I've left out most of it to save space here.
item_samedate python: (item_end - item_start < 1) if item_type == 'Event' else False;">
<metal:block define-slot="entry"
The following condition is key if you can have things
other than reviews within a proposal. Make sure the
item_type is proper for your review/item.
tal:condition="python: item_type=='ug_small_grants_review'">
<tr class="review_entry"><td class="entry_info">
<dt metal:define-macro="listitem"
tal:attributes="class python:test(item_type == 'Event', 'vevent', '')">
I kept all the standard stuff from folder_listing.pt here.
</dt>
<dd tal:condition="item_description">
</dd>
</td>
The following tal:comp block is used to calculate values
across the rows because we do not know the index of the
item the way the batch is iterated.
<tal:comp define = "crit_1 python: item.getObject().restrictedTraverse('criterion_1')[0];
crit_2 python: item.getObject().restrictedTraverse('criterion_2')[0];
">
<td tal:content="structure crit_1"># here</td>
<td tal:content="structure crit_2"># here</td>
<td tal:content="structure python: int(crit_1)+int(crit_2)"># here</td>
</tal:comp>
</tr>
</metal:block>
</tal:block>
</tal:entry>
</dl>
<tr>
<th>Average</th>
<td tal:content="structure c1_avg"># here</td>
<td tal:content="structure c2_avg"># here</td>
<td tal:content="structure avg_sum"># here</td>
</tr>
</tal:listing>
</tal:sum>
<metal:empty metal:define-slot="no_items_in_listing">
<p class="discreet"
tal:condition="not: folderContents"
i18n:translate="description_no_items_in_folder">
There are currently no items in this folder.
</p>
</metal:empty>
</tal:foldercontents>
</metal:listingmacro>
</tbody></table>
回顾对学生的道德好处ClaritySum
下面的tal:sum是我对数据进行计算的地方。如果你是
不操纵数据这是不需要的。请注意,我只是
查看选择字段的第一个字符。
我在这里保留了文件夹_listing.pt中的所有标准内容。
以下tal:comp块用于计算值
因为我们不知道
项指定批处理的迭代方式。
#这里
#这里
#这里
平均值
#这里
#这里
#这里
此文件夹中当前没有任何项目。
请注意,“ug\u small\u grant\u review\u summary\u table”是我为上面更详细显示的模板提供的名称。请看一下Plone全图列表:谢谢……这似乎让我走上了正确的轨道,并允许我使用选项2,这对于调试来说更干净。一旦我发现了这些奇怪之处,我将发布最终解决方案,并提供详细信息。