Phi*_*ley 6 orchardcms orchardcms-1.6
在博客摘要页面 - 列出您的博客帖子的页面 - 我可以通过从每篇博文中看到更多的文本来做.
这可能吗?我无法在设置中的任何地方看到它,并且由于某种原因,形状跟踪不让我看到模板的用途.
我最近需要在Orchard v1.6上做同样的事情.您正在使用形状跟踪,因此您正朝着正确的方向前进.替代品和展示位置的果园文档涵盖了这一点.在Tony Johnson的Argument Exception Blog上有一个很好的例子.
根据Phil的回答,您需要修改当前主题中的placement.info以使用其他视图;
<Match ContentType="BlogPost">
<Match DisplayType="Summary">
<Place Parts_Common_Body_Summary="Content:5;Alternate=Parts_BlogPostSummaryBody"/>
</Match>
</Match>
Run Code Online (Sandbox Code Playgroud)
然后在主题的视图文件夹中添加名为"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>
Run Code Online (Sandbox Code Playgroud)
通过阅读其他帖子,我发现负责此操作的视图是Parts_Common_Body_Summary。所以我从 orchard 的 core/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>
Run Code Online (Sandbox Code Playgroud)
这让我需要在新的备用视图中更改字符串长度:
var body = new HtmlString(Html.Excerpt(bodyHtml, 350).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
Run Code Online (Sandbox Code Playgroud)