在博客摘要页面上 - 一个列出您博客文章的页面 - 我可以通过从每篇博文中看到更多的文本来做到这一点。Orchard博客摘要文本
这可能吗? 我不能在设置中的任何地方看到它,由于某种原因,形状跟踪并不让我看看这个模板是什么。
在博客摘要页面上 - 一个列出您博客文章的页面 - 我可以通过从每篇博文中看到更多的文本来做到这一点。Orchard博客摘要文本
这可能吗? 我不能在设置中的任何地方看到它,由于某种原因,形状跟踪并不让我看看这个模板是什么。
通过阅读其他文章,我发现负责这个视图是Parts_Common_Body_Summary。所以我复制这从果园的核心/ common文件夹,并将它复制跨到我的主题查看文件夹,它重命名为Parts_Blog_Summary
然后我建立这个规则在Placement.info如下之前:
<Match ContentType="BlogPost">
<Match DisplayType="Summary">
<Place Parts_Common_Body_Summary="Content:after;Alternate=Parts_Blog_Summary"/>
</Match>
</Match>
这只是把我改变在新的替代视图中的字符串长度的任务:
var body = new HtmlString(Html.Excerpt(bodyHtml, 350).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
我需要做同样的事情最近在Orchar d v1.6。你正在使用形状追踪,所以你正在朝着正确的方向前进。 orchard documentation for alternates和placement覆盖此。在Tony Johnson's Argument Exception Blog上有这种修改的一个很好的例子。
根据菲尔的回答,您需要修改您当前主题中的placement.info,以便像这样使用替代视图;
<Match ContentType="BlogPost">
<Match DisplayType="Summary">
<Place Parts_Common_Body_Summary="Content:5;Alternate=Parts_BlogPostSummaryBody"/>
</Match>
</Match>
然后在主题的视图文件夹中添加一个名为“Content-BlogPost.Summary.cshtml”的替代部分;
@using Orchard.ContentManagement.ViewModels
@using Orchard.ContentManagement
@using Orchard.Core.Common.Models
@{
ContentItem item = Model.ContentItem;
string title = Model.Title.ToString();
BodyPart bpItem = item.As<BodyPart>();
string linkUrl = Url.ItemDisplayUrl(item);
}
<h4>@Html.ItemDisplayLink(title, item)</h4>
<div class="publishinfo">@Model.ContentItem.CommonPart.PublishedUtc by @Model.ContentItem.CommonPart.Owner.UserName</div>
<div>
<p>@Html.Raw(@bpItem.Text)</p>
</div>