Creating a new page

Posted by Community Admin on 03-Aug-2018 10:34

Creating a new page

All Replies

Posted by Community Admin on 31-Jan-2011 00:00

Hi,

How do i create new page programmatic with new url.Please let me know the documentation url's
  

Posted by Community Admin on 31-Jan-2011 00:00

Hi Jmr,

Please take a look at Sitefinity 4.0 Developers Guide

Greetings,
Ivan Dimitrov
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

Posted by Community Admin on 31-Jan-2011 00:00

Thank you very much..

I need another documentation regarding, How to check given Url is exist or not


Thanks

Posted by Community Admin on 31-Jan-2011 00:00

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

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

Posted by Community Admin on 01-Feb-2011 00:00

Fluent API

If i follow the Developers Guide i am getting one small error.i have attached the file of that error.please took at image and let me know what assembly missed out.

Native API

if i use native API the following error throws,
Not a managed persistent instance. Parameter name: component Actual value was Telerik.Sitefinity.Pages.Model.PageData.

Thanks

Posted by Community Admin on 01-Feb-2011 00:00

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();



Greetings,
Ivan Dimitrov
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

Posted by Community Admin on 01-Feb-2011 00:00

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

Posted by Community Admin on 13-Feb-2011 00:00

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

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

This thread is closed