2013-03-05 78 views
6

在博客摘要頁面上 - 一個列出您博客文章的頁面 - 我可以通過從每篇博文中看到更多的文本來做到這一點。Orchard博客摘要文本

這可能嗎? 我不能在設置中的任何地方看到它,由於某種原因,形狀跟蹤並不讓我看看這個模板是什麼。

回答

4

通過閱讀其他文章,我發現負責這個視圖是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>")); 
5

我需要做同樣的事情最近在Orchar d v1.6。你正在使用形狀追蹤,所以你正在朝着正確的方向前進。 orchard documentation for alternatesplacement覆蓋此。在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> 
相關問題