Create sitefinity admin page
Hi all,
I'd want to add a sitefinity admin page to end of this :
Dashboard Pages Content Design Administration XXXX
Also want to add an user control in this page. Can somebody show me how to do this in C#?
Thanks...
Hi Ozkan,
Sitefinity gives the possibility to manage your backend pages the same way you manage your frontend pages. This is done through the Sitefinity backend:
Administration->Backend Pages
Also you can install and take a look at our Sitefinity SDK.
Here is a code snippet which you can adapt to fit your needs:
PageManager pageManager = PageManager.GetManager();
var pageName =
"Test page"
;
var pageId = Guid.NewGuid();
var pagaDataId = Guid.NewGuid();
// Get the parent node Id
var parentPageNodeId = SiteInitializer.SitefinityNodeId;
var pageGroupName =
"Test Page Group"
;
var pageGroupGuid = Guid.NewGuid();
// Create the page
App.WorkWith().Page().GetManager().Provider.SuppressSecurityChecks =
true
;
App.WorkWith().Page()
.CreateNewPageGroup(parentPageNodeId, pageGroupGuid).Do(p =>
p.Title = pageGroupName;
p.UrlName = Regex.Replace(pageGroupName.ToLower(), @
"[^\w\-\!\$\'\(\)\=\@\d_]+"
,
"-"
);
)
.Done()
.CreateNewStandardPage(pageGroupGuid, pageId, pagaDataId)
.Do(p =>
p.Title = pageName;
p.Name = pageName;
p.Description = pageName;
p.UrlName = Regex.Replace(pageName.ToLower(), @
"[^\w\-\!\$\'\(\)\=\@\d_]+"
,
"-"
);
p.ShowInNavigation =
true
;
p.DateCreated = DateTime.UtcNow;
p.LastModified = DateTime.UtcNow;
p.Page.UIStatus = ContentUIStatus.Published;
p.Page.HtmlTitle = pageName;
p.Page.Title = pageName;
p.Page.Description = pageName;
)
.CheckOut().Publish()
.SaveChanges();
var createdPage = App.WorkWith().Page(pageId).Get();
if
(createdPage !=
null
)
createdPage.ApprovalWorkflowState =
"Published"
;
App.WorkWith().Pages().SaveChanges();
var master = pageManager.EditPage(pagaDataId);
if
(master !=
null
)
// Replace with the desired controll to add on the page
var control =
new
Control();
var pageControl = pageManager.CreateControl<PageDraftControl>(control,
"Content"
);
pageControl.Caption =
"Caption"
;
pageManager.SetControlDefaultPermissions(pageControl);
master.Controls.Add(pageControl);
master = pageManager.PagesLifecycle.CheckIn(master);
pageManager.PagesLifecycle.Publish(master);
master.ApprovalWorkflowState.Value =
"Published"
;
pageManager.SaveChanges();