Skip to content

Commit

Permalink
Merge pull request #31 from rudgr/30-LatestBlogposts.cshtml-macro-num…
Browse files Browse the repository at this point in the history
…berOfPosts-parameter-is-limited-to-3

[30]  fixed numberOfPosts parameter parsing and usage
  • Loading branch information
Warren Buckley authored Oct 11, 2017
2 parents d1d9b77 + a12cb66 commit 953287b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down

0 comments on commit 953287b

Please sign in to comment.