Programatically change a page's sort order

Vote:
 

Hi

I need to write a UI plugin which resets a list of pages to a default sort order.

However, I cannot work out how to programatically change the sort order of a page

I have tried using PagePeerOrder property of the PageData object but this is read-only

e.g. 

            foreach (PageData page in newsItemPages)
            {
                page["PagePeerOrder"] = defaultSortOrder;
            }

Is it possible to programatically change the sort order of a page?

thanks a lot

 

#30239
Jun 08, 2009 18:18
Vote:
 

Hi

your are on the right track, but you need to make some small changes

PageData page2=page.CreateWritableClone();
page2.Property["PagePeerOrder"].Value = defaultSortOrder;
EPiServer.DataFactory.Instance.Save(page2, EPiServer.DataAccess.SaveAction.Publish,
                                                         EPiServer.Security.AccessLevel.NoAccess);

 

#30242
Jun 08, 2009 22:14
Vote:
 

Thanks a lot - that works great...

 

Chris

#30255
Jun 09, 2009 11:45
Ted
Vote:
 

Nowadays you can use MetaDataProperties.PagePeerOrder instead of "PagePeerOrder" to avoid manually typing the property name for the sort order. It's still not available as a separate property on PageData, though.

#143307
Jan 20, 2016 0:41
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.