From 03c48d3b1a76f8afee15acbdda0d14b760c18598 Mon Sep 17 00:00:00 2001 From: Sofie Date: Mon, 28 Nov 2022 13:35:06 +0100 Subject: [PATCH] Use different macro approach to LatestBlogposts macro --- .../Views/ContentPage.cshtml | 4 ++++ .../MacroPartials/LatestBlogposts.cshtml | 13 +++++-------- .../umbraco/Data/Umbraco.sqlite.db | Bin 1130496 -> 1134592 bytes .../umbraco/Data/Umbraco.sqlite.db-shm | Bin 32768 -> 32768 bytes .../umbraco/Data/Umbraco.sqlite.db-wal | Bin 4264232 -> 2838712 bytes 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Umbraco.Docs.Samples.Web/Views/ContentPage.cshtml b/Umbraco.Docs.Samples.Web/Views/ContentPage.cshtml index 98e125d..7e9c4d0 100644 --- a/Umbraco.Docs.Samples.Web/Views/ContentPage.cshtml +++ b/Umbraco.Docs.Samples.Web/Views/ContentPage.cshtml @@ -33,6 +33,10 @@
+ +
+

Members

+

Cheat sheet - Standard Model Properties

diff --git a/Umbraco.Docs.Samples.Web/Views/MacroPartials/LatestBlogposts.cshtml b/Umbraco.Docs.Samples.Web/Views/MacroPartials/LatestBlogposts.cshtml index bafaf2e..34d0aa9 100644 --- a/Umbraco.Docs.Samples.Web/Views/MacroPartials/LatestBlogposts.cshtml +++ b/Umbraco.Docs.Samples.Web/Views/MacroPartials/LatestBlogposts.cshtml @@ -10,11 +10,8 @@ @{ var startNodeId = Model.MacroParameters["startNodeId"] ?? Model.Content.Id; - var numberOfPosts = 3; - if (Model.MacroParameters["numberOfPosts"] != null) - { - int.TryParse((string)Model.MacroParameters["numberOfPosts"], out numberOfPosts); - } + + var numberOfMorePosts = Model.GetParameterValue("numberOfPosts"); } @if (startNodeId != null) @@ -35,7 +32,7 @@ //Gets all blogposts to calculate pages var blogposts = startNode.Children.OrderBy(x => x.CreateDate).ToList(); - var pageCount = (int)Math.Ceiling((double)blogposts.Count / (double)numberOfPosts); + var pageCount = (int)Math.Ceiling((double)blogposts.Count / (double)numberOfMorePosts); //gets the page from the querystring and sets it to one if it is out of range var page = 1; if (httpContext != null && !string.IsNullOrEmpty(httpContext.Request.Query["page"])) @@ -47,7 +44,7 @@ } } //Gets the blogposts for the current page - var pagedBlogposts = blogposts.Skip((page - 1) * numberOfPosts).Take(numberOfPosts).ToList(); + var pagedBlogposts = blogposts.Skip((page - 1) * numberOfMorePosts).Take(numberOfMorePosts).ToList(); if (pagedBlogposts.Count > 0) { @@ -69,7 +66,7 @@
} - if (blogposts.Count > numberOfPosts) + if (blogposts.Count > numberOfMorePosts) {