Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Umbraco.RenderMacro("PaginationExample")@inherits UmbracoTemplatePage
- @{
- Layout = "umbLayout.cshtml";
- // If the editor has not explicitly provided the "Page title" property page
- // then just show the name of the page otherwise show the provided title
- var pageTitle = string.IsNullOrWhiteSpace(CurrentPage.Title)
- ? CurrentPage.Name
- : CurrentPage.Title;
- // Model.Content is the current page that we're on
- // AncestorsOrSelf is all of the ancestors this page has in the tree
- // (1) means: go up to level 1 and stop looking for more ancestors when you get there
- // First() gets the first ancestor found (the home page, on level 1)
- var homePage = CurrentPage.AncestorsOrSelf(1).First();
- // Find all pages with document type alias umbNewsOverview
- // We do that using the plural, umbNewsOverviews (note the extra "s" in the end)
- // Then take the first one, as we know there will only be on news overview page
- var newsOverview = homePage.umbNewsOverviews.First();
- // Similar to above: find all pages with document type umbNewsItem under the news overview page
- // Then order them, first by publishDate (a property the editor can explicitly set on the news item)
- // and then by createDate, which is set by Umbraco automatically when a page gets created.
- var newsItems = newsOverview.umbNewsItems.OrderBy("publishDate desc, createDate desc").Take(5);
- }
- <script>
- window.onload=toBottom;
- function toBottom() {
- window.scrollTo(0, 800);
- }
- </script>
- <!-- Main -->
- <br><br>
- <!-- /Main -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement