Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
I have a bunch of nodes in a list view which are sorted by a custom field "postDate"
and I've created a next/previous button to navigate through the posts:
@{ var blogPost = Model.Content; } <nav aria-label="..."> <ul class="pagination"> <li class="page-item @((blogPost.Previous() == null ? "disabled" : null))"> <a class="page-link" href="@((blogPost.Previous() != null ? blogPost.Previous().Url : null))" tabindex="-1">Previous</a> </li> <li class="page-item @((blogPost.Next() == null ? "disabled" : null))"> <a class="page-link" href="@((blogPost.Next() != null ? blogPost.Next().Url : null))" tabindex="-1">Next</a> </li> </ul> </nav>
The problem I'm having is that the nav buttons are getting the next/previous post based on the Sort Order, which isn't the same as postDate:
How do I make it so that it navigates to the next post via postDate and not sortOrder? Thanks :) I'm using Umbraco 7.6.1
Hi Milly,
Have you tried appending the blogPost Url with a .CreateDate?
First you'd need to change that top snippet to
var blogPost = Model.Content.Url;
Then append here
blogPost.Next().CreateDate
Would that work?
Emma
I wrote this partial for my site.
You are welcome to use it.
https://gist.github.com/prjseal/85613cb05bea0d62e2fdc4515b46c1d1#file-next-and-prev-buttons-partial-for-umbraco
Kind regards
Paul
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Sorting and Creating Next/Previous Buttons
Hello,
I have a bunch of nodes in a list view which are sorted by a custom field "postDate"
and I've created a next/previous button to navigate through the posts:
The problem I'm having is that the nav buttons are getting the next/previous post based on the Sort Order, which isn't the same as postDate:
How do I make it so that it navigates to the next post via postDate and not sortOrder? Thanks :) I'm using Umbraco 7.6.1
Hi Milly,
Have you tried appending the blogPost Url with a .CreateDate?
First you'd need to change that top snippet to
var blogPost = Model.Content.Url;
Then append here
blogPost.Next().CreateDate
Would that work?
Emma
I wrote this partial for my site.
You are welcome to use it.
https://gist.github.com/prjseal/85613cb05bea0d62e2fdc4515b46c1d1#file-next-and-prev-buttons-partial-for-umbraco
Kind regards
Paul
is working on a reply...