More in this section

Forums / General Discussions / Creating a new page

Creating a new page

8 posts, 1 answered
  1. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    31 Jan 2011
    Link to this post
    Hi,

    How do i create new page programmatic with new url.Please let me know the documentation url's
      
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    31 Jan 2011
    Link to this post
    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
  3. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    31 Jan 2011
    Link to this post
    Thank you very much..

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


    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    31 Jan 2011
    Link to this post
    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
  5. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    01 Feb 2011
    Link to this post

    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

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Feb 2011
    Link to this post
    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
    Answered
  7. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    01 Feb 2011
    Link to this post
    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
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 Feb 2011
    Link to this post
    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
8 posts, 1 answered