Orchard博客摘要文本

时间:2013-03-05 16:31:40

标签: orchardcms orchardcms-1.6

在博客摘要页面 - 列出您博客文章的页面 - 我可以通过每篇博文中看到更多文字来做。

这可能吗? 我无法在设置中的任何地方看到它,并且出于某种原因,形状跟踪不允许我看到模板的用途。

2 个答案:

答案 0 :(得分:5)

我最近需要在Orchard v1.6上做同样的事情。您正在使用形状跟踪,因此您正朝着正确的方向前进。 orchard documentation for alternatesplacement涵盖了此内容。这是Tony Johnson's Argument Exception Blog上这种修改的一个很好的例子。

根据Phil的回答,您需要修改当前主题中的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>

答案 1 :(得分:4)

通过阅读其他帖子,我发现负责此操作的视图是 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>

这只是让我在新的备用视图中改变字符串长度的任务:

var body = new HtmlString(Html.Excerpt(bodyHtml, 350).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));