+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Dynamic Page Creation (in SQL)

Dynamic Page Creation (in SQL)

4 posts, 0 answered
  1. Scott Bradley
    Scott Bradley avatar
    27 posts
    Registered:
    20 Jan 2010
    06 Apr 2011
    Link to this post
    Does sql exist somewhere to create pages in tsql?  I am using CodeSmith to create some admin controls for a custom database, and it would be nice to have Codesmith Create the tsql to create the pages (maybe even drop the controls on the page too).  I have a ton of tables that require a searchable interface page and subsequent edit form page.  I don't want to have to do that manually through the gui.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    06 Apr 2011
    Link to this post
    Hello Scott ,

    We use data layer Open Access ORM and we do no use direct sql queries. We work with the API and we have methods that create objects which we use. You can use the API to create pages, but you should create a tool that will export the entire data you have.

    http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-pages.html

    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. Scott Bradley
    Scott Bradley avatar
    27 posts
    Registered:
    20 Jan 2010
    06 Apr 2011
    Link to this post

    I think the following code is what you want me to use.  However, when I put that into a C# ascx, I get a squiggly under the GET(); on the following line.  Bool does not contain a definition for Get(); error.

    SaveChanges().Get();

    public PageNode CreateNewFrontendPage(string name, string title, string urlName)
    {
        //We need a page manager object so we can get a template for the page
        //but Template facade will be introduced with the official release

        Telerik.Sitefinity.Modules.Pages.PageManager pManager = new Telerik.Sitefinity.Modules.Pages.PageManager();
        Guid templateGuid = pManager.GetTemplates().First().Id;
        PageNode newPageNode = App.WorkWith().Page()
                                 .CreateNewStandardPage(PageLocation.Frontend)
                                 .Do(p =>
                                 {
                                     p.Name = name;
                                     p.Title = title;
                                     //unique url of the page
                                     //this property is required
                                     p.UrlName = urlName;
                                     p.ShowInNavigation = true;
                                     p.LastModified = DateTime.UtcNow;
                                     p.DateCreated = DateTime.UtcNow;
                                     //set menu name
                                     p.Page.Title = name;
                                     //set title which appears in page header
                                     p.Page.HtmlTitle = title;
                                     p.Description = "Some description";
                                 })
                                 .CheckOut()
            //set the page template
                                    .SetTemplateTo(templateGuid)
            //when we are done with editing we want to make the page live
            //the other option is to CheckIn() however this only save changes
            //to a new page draft without publishing it
                                    .Publish()
                                .SaveChanges().Get();
        SiteMapBase.Cache.Flush();
        return newPageNode;
    }

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    11 Apr 2011
    Link to this post
    Hello Scott Bradley,

    We have had some changes in the Pages Fluent API. Can you please try using SaveAndContinue:
    Telerik.Sitefinity.Modules.Pages.PageManager pManager = new Telerik.Sitefinity.Modules.Pages.PageManager();
    Guid templateGuid = pManager.GetTemplates().First().Id;
    PageNode newPageNode = App.WorkWith().Page()
                             .CreateNewStandardPage(PageLocation.Frontend)
                             .Do(p =>
                             {
                                 p.Name = name;
                                 p.Title = title;
                                 //unique url of the page
                                 //this property is required
                                 p.UrlName = urlName;
                                 p.ShowInNavigation = true;
                                 p.LastModified = DateTime.UtcNow;
                                 p.DateCreated = DateTime.UtcNow;
                                 //set menu name
                                 p.Page.Title = name;
                                 //set title which appears in page header
                                 p.Page.HtmlTitle = title;
                                 p.Description = "Some description";
                             })
                             .CheckOut()
        //set the page template
                                .SetTemplateTo(templateGuid)
        //when we are done with editing we want to make the page live
        //the other option is to CheckIn() however this only save changes
        //to a new page draft without publishing it
                                .Publish()
                            .SaveAndContinue().Get();
    SiteMapBase.Cache.Flush();c

    We will update the developer's guide to reflect the changes.

    Greetings,
    Radoslav Georgiev
    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
4 posts, 0 answered