diff --git a/src/Foundation/Features/Blocks/PageListBlock/PageListBlock.cs b/src/Foundation/Features/Blocks/PageListBlock/PageListBlock.cs index 46c8ff56d..b5b60f27f 100644 --- a/src/Foundation/Features/Blocks/PageListBlock/PageListBlock.cs +++ b/src/Foundation/Features/Blocks/PageListBlock/PageListBlock.cs @@ -50,7 +50,10 @@ public class PageListBlock : FoundationBlockData [Display(Name = "Include all levels", GroupName = SystemTabNames.Content, Order = 90)] public virtual bool Recursive { get; set; } - [Display(Name = "Template of pages listing", GroupName = SystemTabNames.Content, Order = 100)] + [Display(Name = "Page Listing Display Style", + Description = "Display template to use for page list", + GroupName = SystemTabNames.Content, + Order = 100)] [SelectOne(SelectionFactoryType = typeof(TemplateListSelectionFactory))] public virtual string Template { get; set; } @@ -58,11 +61,18 @@ public class PageListBlock : FoundationBlockData [SelectOne(SelectionFactoryType = typeof(PreviewOptionSelectionFactory))] public virtual string PreviewOption { get; set; } - [Display(Name = "Overlay color (only for Card template)", Description = "Apply for Card template", GroupName = SystemTabNames.Content, Order = 120)] + [Display(Name = "Bootstrap Card Image Display Ratio (Bootstrap Card Group display only)", + Description = "Display ratio for card image when using Bootstrap Card Group template", + GroupName = SystemTabNames.Content, + Order = 115)] + [SelectOne(SelectionFactoryType = typeof(BootstrapCardRatioSelectionFactory))] + public virtual string BootstrapCardRatioOption { get; set; } + + [Display(Name = "Overlay color (non-Bootstrap Card template only)", Description = "Apply for non-Bootstrap Card template", GroupName = SystemTabNames.Content, Order = 120)] [ClientEditor(ClientEditingClass = "foundation/Editors/ColorPicker")] public virtual string OverlayColor { get; set; } - [Display(Name = "Overlay text color (only for Card template)", Description = "Apply for Card template", GroupName = SystemTabNames.Content, Order = 130)] + [Display(Name = "Overlay text color (non-Bootstrap Card template only)", Description = "Apply for non-Bootstrap Card template", GroupName = SystemTabNames.Content, Order = 130)] [ClientEditor(ClientEditingClass = "foundation/Editors/ColorPicker")] public virtual string OverlayTextColor { get; set; } @@ -75,6 +85,7 @@ public override void SetDefaultValues(ContentType contentType) IncludePublishDate = false; Template = TemplateSelections.Grid; PreviewOption = PreviewOptions.Full; + BootstrapCardRatioOption = BootstrapCardRatioSelections.FourThree; SortOrder = FilterSortOrder.PublishedDescending; OverlayColor = "black"; OverlayTextColor = "white"; diff --git a/src/Foundation/Features/Blocks/PageListBlock/PageListBlockViewModel.cs b/src/Foundation/Features/Blocks/PageListBlock/PageListBlockViewModel.cs index 4214a6c91..c5368cd22 100644 --- a/src/Foundation/Features/Blocks/PageListBlock/PageListBlockViewModel.cs +++ b/src/Foundation/Features/Blocks/PageListBlock/PageListBlockViewModel.cs @@ -9,6 +9,7 @@ public PageListBlockViewModel(PageListBlock block) : base(block) ShowPublishDate = block.IncludePublishDate; Padding = block.Padding; SetPreviewOptionValue(block.PreviewOption); + BootstrapCardRatio = block.BootstrapCardRatioOption; } public string Heading { get; set; } @@ -27,6 +28,7 @@ private void SetPreviewOptionValue(string option) else if (option.Equals("1")) PreviewOption = 12; } + public string BootstrapCardRatio { get; set; } } public class PageListPreviewViewModel @@ -47,5 +49,6 @@ public PageListPreviewViewModel(PageData page, PageListBlock block) ShowIntroduction = block.IncludeTeaserText; ShowPublishDate = block.IncludePublishDate; } + public string BootstrapCardRatio { get; set; } } } diff --git a/src/Foundation/Features/Blocks/PageListBlock/Views/PageListBlock.cshtml b/src/Foundation/Features/Blocks/PageListBlock/Views/PageListBlock.cshtml index 206847ddd..1a6099724 100644 --- a/src/Foundation/Features/Blocks/PageListBlock/Views/PageListBlock.cshtml +++ b/src/Foundation/Features/Blocks/PageListBlock/Views/PageListBlock.cshtml @@ -16,6 +16,10 @@ { switch (Model.CurrentBlock.Template) { + case TemplateSelections.BootstrapCardGroup: + @await Html.PartialAsync("/Features/Blocks/PageListBlock/Views/Templates/_BootstrapCardGroupTemplate.cshtml", Model) + break; + case TemplateSelections.Grid: @await Html.PartialAsync("/Features/Blocks/PageListBlock/Views/Templates/_GridTemplate.cshtml", Model) break; diff --git a/src/Foundation/Features/Blocks/PageListBlock/Views/Templates/_BootstrapCardGroupTemplate.cshtml b/src/Foundation/Features/Blocks/PageListBlock/Views/Templates/_BootstrapCardGroupTemplate.cshtml new file mode 100644 index 000000000..71affcc97 --- /dev/null +++ b/src/Foundation/Features/Blocks/PageListBlock/Views/Templates/_BootstrapCardGroupTemplate.cshtml @@ -0,0 +1,47 @@ +@model PageListBlockViewModel +@using EPiServer.Core.Html +@using Foundation.Features.Blocks.PageListBlock +@using Foundation.Features.Shared.SelectionFactories + +@{ + int col = 12/Model.PreviewOption; +} + +@if (Model.Pages != null && Model.Pages.Any()) +{ +
+ @foreach (var pageModel in Model.Pages) + { + var foundationPage = pageModel.Page as FoundationPageData; + var imageCol = pageModel.PreviewOption == PreviewOptions.Full ? 12 : (pageModel.PreviewOption == PreviewOptions.Half ? 6 : 4); +
+
+
+ @foundationPage.MetaTitle +
+
+
@(@Html.Raw(TextIndexer.StripHtml(pageModel != null ? foundationPage.MetaTitle : pageModel.Page.Name, 40)) + "...")
+ @if(Model.ShowIntroduction) { +
+

@Html.Raw(TextIndexer.StripHtml(foundationPage.TeaserText, 200))

+
+ } + +
+ @if(Model.ShowPublishDate) + { + + } +
+
+ + } + +
+} \ No newline at end of file diff --git a/src/Foundation/Features/Shared/SelectionFactories/BootstrapCardRatioSelectionFactory.cs b/src/Foundation/Features/Shared/SelectionFactories/BootstrapCardRatioSelectionFactory.cs new file mode 100644 index 000000000..1be8d08c8 --- /dev/null +++ b/src/Foundation/Features/Shared/SelectionFactories/BootstrapCardRatioSelectionFactory.cs @@ -0,0 +1,24 @@ +namespace Foundation.Features.Shared.SelectionFactories +{ + public static class BootstrapCardRatioSelections + { + public const string OneOne = "ratio-1x1"; + public const string FourThree = "ratio-4x3"; + public const string SixteenNine = "ratio-16x9"; + public const string TwentyOneNine = "ratio-21x9"; + } + + public class BootstrapCardRatioSelectionFactory : ISelectionFactory + { + public IEnumerable GetSelections(ExtendedMetadata metadata) + { + return new ISelectItem[] + { + new SelectItem { Value = BootstrapCardRatioSelections.FourThree, Text = "4x3"}, + new SelectItem { Value = BootstrapCardRatioSelections.OneOne, Text = "1x1"}, + new SelectItem { Value = BootstrapCardRatioSelections.SixteenNine, Text = "16x9"}, + new SelectItem { Value = BootstrapCardRatioSelections.TwentyOneNine, Text = "21x9"}, + }; + } + } +} diff --git a/src/Foundation/Features/Shared/SelectionFactories/TemplateListSelectionFactory.cs b/src/Foundation/Features/Shared/SelectionFactories/TemplateListSelectionFactory.cs index be666431c..5be47543a 100644 --- a/src/Foundation/Features/Shared/SelectionFactories/TemplateListSelectionFactory.cs +++ b/src/Foundation/Features/Shared/SelectionFactories/TemplateListSelectionFactory.cs @@ -9,6 +9,7 @@ public static class TemplateSelections public const string Highlight = "Highlight"; public const string Card = "Card"; public const string Insight = "Insight"; + public const string BootstrapCardGroup = "Bootstrap Card Group"; } public class TemplateListSelectionFactory : ISelectionFactory @@ -24,6 +25,7 @@ public IEnumerable GetSelections(ExtendedMetadata metadata) new SelectItem { Value = TemplateSelections.Highlight, Text = "Highlight panel"}, new SelectItem { Value = TemplateSelections.Card, Text = "Card"}, new SelectItem { Value = TemplateSelections.Insight, Text = "Insight"}, + new SelectItem { Value = TemplateSelections.BootstrapCardGroup, Text = "Bootstrap Card Group"}, }; } }