mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Adding Common.Body.Summary template that displays a generated body excerpt
- Added body summary template - Added an Ellipsize(int length) string extension - Added an Excerpt(string markup, int length) HtmlHelper extension - Added a LongestMatch method to ContentPartTemplateResult (pretty much a copy/paste from item) to get the fallback on filename functionality - Changed the BodyDriver to try to display SummaryAdmin or Summary template variations on Body if the displayType fits --HG-- branch : dev
This commit is contained in:
@@ -20,11 +20,12 @@ namespace Orchard.Core.Common.Controllers {
|
||||
|
||||
// \/\/ Haackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
||||
protected override DriverResult Display(BodyAspect part, string displayType) {
|
||||
var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text)};
|
||||
var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) };
|
||||
|
||||
return Combined(
|
||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPre").Location("primary", "5") : null,
|
||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Manage").Location("primary", "5") : null,
|
||||
ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5"),
|
||||
ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"),
|
||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPost").Location("primary", "5") : null);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
|
||||
<%--//doing excerpt generation on the way out for now so we don't stick ourselves with needing to regen excerpts for existing data
|
||||
//also, doing this here, inline, until we have a pluggable processing model (both in and out)
|
||||
//also, ...this is ugly--%>
|
||||
<%=string.Format(
|
||||
"<p>{0} {1}</p>",
|
||||
Html.Excerpt(Model.Text, 200).ToString().Replace("\r\n", "</p>\r\n<p>"),
|
||||
Html.ItemDisplayLink(T("[more]").ToString(), Model.BodyAspect.ContentItem)) %>
|
@@ -225,6 +225,7 @@
|
||||
<Content Include="Themes\Views\DisplayTemplates\Items\ContentItem.ascx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Summary.ascx" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\ManageWrapperPost.ascx" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\ManageWrapperPre.ascx" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Manage.ascx" />
|
||||
|
Reference in New Issue
Block a user