Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • k 256 posts 654 karma points
    May 27, 2019 @ 10:45
    k
    0

    Previous/Next Umbraco 8

    Hello,

    I am using Previous() and Next() on Umbraco 8 but it is not working.

    Has someone used it on umbraco 8 ?

    Thanks for helping.

    Kusum

  • Marc Goodson 2141 posts 14324 karma points MVP 8x c-trib
    Jun 11, 2019 @ 19:48
    Marc Goodson
    0

    Hi K

    I think removed...

    they were here in V7:

    https://github.com/umbraco/Umbraco-CMS/blob/v7/dev/src/Umbraco.Web/PublishedContentExtensions.cs

    but gone in V8:

    https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/PublishedContentExtensions.cs

    Aha - there is a discussion on the why's and where's here:

    https://github.com/umbraco/Umbraco-CMS/issues/4839

    Looks like from that discussion you might be able to use SiblingsAndSelf() to get an IEnumerable

    regards

    Marc

  • k 256 posts 654 karma points
    Jun 25, 2019 @ 16:36
    k
    101

    Below code is working fine on Umbraco 8

      @{
    
          var newsList = Model.Parent.Children("alias").ToList();
            var currentIndexInNewsList = newsList.FindIndex(x => x.Id.Equals(Model.Id));
           var  totalResults = newsList.Count();
    
            if (currentIndexInNewsList > -1)
                    {
    
                     if (currentIndexInNewsList > 0)
                        {
                            var previousItem = newsList[currentIndexInNewsList - 1]; 
                            <div class="col-xl-6 col-lg-6 col-sm-12 prevFooter">
                                    <a href="@previousItem.Url"><span><i class="fas fa-arrow-left"></i></span>Previous Project</a>
                                </div>
    
                        }   
                        if (totalResults-1 > currentIndexInNewsList)
                        {
                            var nextItem = newsList[currentIndexInNewsList + 1];
                             <div class="col-xl-6 col-lg-6 col-sm-12 nextFooter">
                                <a href="@nextItem.Url"><span></span>Next Project</a>
                            </div>
    
                        }
    
    
        }
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft