Orchard Core中Detail Template与Summary Template分别在什么场景下显示?
Orchard Core Summary Template 说明
核心作用
Summary Template(摘要模板)是Orchard Core内容展示体系中与Detail Template(详情模板)配套的轻量化模板:你已经配置的Detail Template用于输出内容项的完整展示逻辑,而Summary Template仅用于输出内容项的核心概要信息,避免在非详情场景加载冗余代码,同时适配列表类场景的视觉展示逻辑。
常见显示场景
- 内容聚合列表页:比如站内搜索结果页、分类内容列表页,同一页面需要同时展示多个内容项时,默认调用Summary Template渲染每个条目的摘要
- 关联内容引用预览:如果其他内容项通过Content Picker(内容选择器)字段引用了这个轮播Widget,引用处的预览效果默认由Summary Template控制
- 内容容器子项展示:如果你将该Widget放到列表容器、组合Widget这类父级内容容器中,父容器配置为展示子项摘要时,会调用该Widget的Summary Template
- 后台内容管理列表:后台内容管理界面的内容列表条目预览,也会优先调用Summary Template渲染
如果你的轮播Widget不需要在上述场景展示完整效果,Summary Template可以配置极简的提示内容即可,无需加载完整的轮播逻辑,减少冗余代码。
你提供的轮播逻辑Liquid代码(格式化后):
{%- assign imageIndex = 0 -%} {%- assign max = Model.ContentItem.Content.ImageRotator.ImageRotatorImages.Paths.size -%} {%- assign minute = "now" | date: "%M" | plus: 0 -%} {%- if minute <= 30 -%} {%- assign target = "now" | date: "%H" | plus: 0 -%} {%- else -%} {%- assign target = "now" | date: "%H" | plus: 23 -%} {%- endif -%} {%- for i in (0..48) -%} {%- if i == target -%} <img src="{{Model.ContentItem.Content.ImageRotator.ImageRotatorImages.Paths[imageIndex] | asset_url}}" {% if Model.ContentItem.Content.ImageRotator.AltText and Model.ContentItem.Content.ImageRotator.AltText.Text.size > 0 -%} alt="{{Model.ContentItem.Content.ImageRotator.AltText.Text}}"{%- endif -%} {%- if Model.ContentItem.Content.ImageRotator.ID and Model.ContentItem.Content.ImageRotator.ID.Text.size > 0 -%} id="{{Model.ContentItem.Content.ImageRotator.ID.Text}}"{%- endif -%} {%- if Model.ContentItem.Content.ImageRotator.Class and Model.ContentItem.Content.ImageRotator.Class.Text.size > 0 -%} class="{{Model.ContentItem.Content.ImageRotator.Class.Text}}"{%- endif -%} {%- if Model.ContentItem.Content.ImageRotator.Height and Model.ContentItem.Content.ImageRotator.Height.Text.size > 0 -%} height="{{Model.ContentItem.Content.ImageRotator.Height.Text}}"{%- endif -%} {%- if Model.ContentItem.Content.ImageRotator.Width and Model.ContentItem.Content.ImageRotator.Width.Text.size > 0 -%} width="{{Model.ContentItem.Content.ImageRotator.Width.Text}}"{%- endif %} > {%- break -%} {%- endif -%} {%- assign imageIndex = imageIndex | plus: 1 -%} {%- if imageIndex >= max -%} {%- assign imageIndex = 0 -%} {%- endif -%} {%- endfor -%}
内容的提问来源于stack exchange,提问作者Greg Finzer
相关产品推荐
相关产品推荐

