The correct way to add pages by code

What is the correct way of adding a page by code?
Create a page.
Set Visitor access for the page and all subpages.
Set Write Access to Admins for the page and all subpages
Handling different versions, publish, save a draft, etc.

Can’t find it in the documentation

Litium version: 7.4

Thank you!

Some example here:

var page = new Page(fieldTemplateSystemId, parentPageSystemId);
            page.AccessControlList.Add(new AccessControlEntry(new Operation(Operations.Entity.Read), visitorGroupSystemId));
            page.AccessControlList.Add(new AccessControlEntry(new Operation(Operations.Entity.Write), adminGroupSystemId));
            page.Status = Common.ContentStatus.Published;

In order for back office to have the same content from the changes you made in code, a good idea is to make the changes to a DraftPage of the new page you created and then publish that one.

var draftPage = _draftPageService.Get(page.SystemId).MakeWritableClone();
// make changes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.