+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Manager.GetPages sorting based on ordinal - second attempt

Manager.GetPages sorting based on ordinal - second attempt

4 posts, 0 answered
  1. IH
    IH avatar
    11 posts
    Registered:
    13 Jan 2010
    10 May 2010
    Link to this post
    Hi,

    I am trying to create a custom sitemap and was trying to sort the pages based on their ordinal set from the sitefinity sitemap (on the left hand side under Pages).

    I came across this sample provided by the Telerik team: http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/sort-the-ilist-output-from-cmsmanager-getpages.aspx

    Unfortunately this doesn't work in my case.

    I have changed

    if (page.PageType == CmsPageType.Group) 

    to Normal but what it does that when comparing, compare ordinals of all the pages, including the child pages in the hierarchy and return them, for example consider this sitemap:

    - Products (ord 1)
    - Company (ord 2)
    - - About (ord 1)
    - - Portfolio (ord 2)
    - - Contact (ord 3)

    it will sort it like:

    - Products (ord 1)
    - - About (ord 1)
    - Company (ord 2)
    - - Portfolio (ord 2)
    - - Contact (ord 3)

    So can somebody think of better logic to sort pages?

    Thanks
    IH

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 May 2010
    Link to this post
    Hi IH,

    You can take a look at the code in the attached sample user control. It sorts the pages using ordinal as it should.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. IH
    IH avatar
    11 posts
    Registered:
    13 Jan 2010
    11 May 2010
    Link to this post

    Hello,

    Thank you for your reply, but that still doesn't work.

    This is what I have:

      Private Function GetPages2(ByVal parentId As Nullable(Of Guid)) As List(Of ICmsPage)
        Dim manager As New CmsManager()
        Dim pages As IList
        If parentId.HasValue Then
            pages = manager.GetPages(parentId)
        Else
            pages = manager.GetPages()
        End If
          
        Dim newColl = pages.Cast(Of ICmsPage)().ToList()
        newColl.Sort(Function(x, y) x.Ordinal.CompareTo(y.Ordinal))
        Return newColl
    End Function

    This still doesn't work sorry.

    Any other solution for this simple ordinal sort job?

    Thanks
    IH
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 May 2010
    Link to this post
    Hello IH,

    I am sorry but the control I have sent you produces exactly the same ordering of the pages as they are in the site map, refer to attached image. The other option is to bind the TreeView to a SiteMapDataSource.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered