Creating a new page
Hi,
How do i create new page programmatic with new url.Please let me know the documentation url's
Hi Jmr,
Please take a look at Sitefinity 4.0 Developers Guide
Greetings,
Ivan Dimitrov
the Telerik team
Thank you very much..
I need another documentation regarding, How to check given Url is exist or not
Thanks
Hello Jmr,
You can use PagesFacade and LINQ expression to get a page with a given url. Here are the properties of PageNode that you can use.
Best wishes,
Ivan Dimitrov
the Telerik team
Hi Jmr,
Try using the code below
Telerik.Sitefinity.Modules.Pages.PageManager pManager =
new
Telerik.Sitefinity.Modules.Pages.PageManager();
Guid templateGuid = pManager.GetTemplates().First().Id;
var newPageNode = App.WorkWith().Page()
.CreateNewStandardPage(PageLocation.Frontend)
.Do(p =>
p.Name =
"name"
;
p.Title =
"title"
;
p.UrlName =
"urlName"
;
p.ShowInNavigation =
true
;
p.LastModified = DateTime.UtcNow;
p.DateCreated = DateTime.UtcNow;
p.Page.Title =
"name"
;
//set title which appears in page header
p.Page.HtmlTitle =
"title"
;
p.Description =
"Some description"
;
)
.CheckOut()
.SetTemplateTo(templateGuid)
.Publish()
.SaveChanges();
SiteMapBase.Cache.Flush();
Thanks for your Quick reply..
The above code exactly working fine.now i want to do with next level of page creation.
i want my custom template instead of pManager.GetTemplates().First().Id;
and i want to create page inside the group instead of .CreateNewStandardPage(PageLocation.Frontend)
please check my code which i made it.but it have some error(No items found in the sequence.) with the following lines
Guid templateGuid = pManager.GetTemplates().Where(template => template.Name == "UserDynamicTemplate").First().Id;
Guid parentGuid = App.WorkWith().Pages().Where(pages => pages.Name == "PlayGroup").Get().First().Id;
and my full code follows,
PageManager pManager = new PageManager();
Guid templateGuid = pManager.GetTemplates().Where(template => template.Name == "UserDynamicTemplate").First().Id;
Guid parentGuid = App.WorkWith().Pages().Where(pages => pages.Name == "PlayGroup").Get().First().Id;
//Guid templateGuid = pManager.GetTemplates().First().Id;
try
var newPageNode = App.WorkWith().Page()
.CreateNewStandardPage(parentGuid,new Guid())
.Do(p =>
p.Name = name;
p.Title = title;
p.UrlName = urlName;
p.ShowInNavigation = false;
p.LastModified = DateTime.UtcNow;
p.DateCreated = DateTime.UtcNow;
p.Page.Title = title;
p.Page.HtmlTitle = title;
p.Description = name;
)
.CheckOut()
.SetTemplateTo(templateGuid)
.Publish()
.SaveChanges();
SiteMapBase.Cache.Flush();
catch
throw;
Please let me know if my question is not understandable
Thanks
Jmr
Hi Jmr,
Try using SingleOrDefault(). You get the error, because there is no template with the name you are looking for and then you cal Get().First().Id
All the best,
Ivan Dimitrov
the Telerik team