From a12cb667027d1a6f845109972f4f8be8b88648c2 Mon Sep 17 00:00:00 2001 From: Rutger Buijzen Date: Tue, 10 Oct 2017 13:26:28 +0200 Subject: [PATCH] [30] fixed numberOfPosts parameter parsing and usage --- .../Views/MacroPartials/LatestBlogposts.cshtml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.SampleSite.Website/Views/MacroPartials/LatestBlogposts.cshtml b/src/Umbraco.SampleSite.Website/Views/MacroPartials/LatestBlogposts.cshtml index 5b13b142..6f919a28 100644 --- a/src/Umbraco.SampleSite.Website/Views/MacroPartials/LatestBlogposts.cshtml +++ b/src/Umbraco.SampleSite.Website/Views/MacroPartials/LatestBlogposts.cshtml @@ -3,13 +3,17 @@ @inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var startNodeId = Model.MacroParameters["startNodeId"] != null ? Model.MacroParameters["startNodeId"] : Model.Content.Id; - var numberOfPosts = Model.MacroParameters["numberOfPosts"] != null ? Model.MacroParameters["numberOfPosts"] : 3; + var numberOfPosts = 3; + if (Model.MacroParameters["numberOfPosts"] != null) + { + int.TryParse((string)Model.MacroParameters["numberOfPosts"], out numberOfPosts); + } } @if (startNodeId != null) { @* Get the starting page *@ var startNode = Umbraco.TypedContent(startNodeId); - var blogposts = startNode.Children.OrderByDescending(x => x.CreateDate).Take(3); + var blogposts = startNode.Children.OrderByDescending(x => x.CreateDate).Take(numberOfPosts); if (blogposts.Any()) {