Dynamically created pages content not visible unless logged

Posted by Community Admin on 04-Aug-2018 23:16

Dynamically created pages content not visible unless logged in as admin

All Replies

Posted by Community Admin on 03-Nov-2011 00:00

I'm creating pages dynamically and adding controls during page creation. The problem I'm experiencing is the page content for these dynamically created pages is not visible UNLESS I'm logged in to Sitefinity. The page template appears but no content. Content for pages created within the UI appears whether logged in or not. Content added via the UI to a dynamically created page will appear.

There is no value in the sf_control_properties for these dynamically created controls. I didn't see any explicit permissions settings aside from InheritsPermissions for the controls (which didn't help). Viewing the page permissions settings in the UI, the dynamically created pages share the same permissions as the pages created via Sitefinity. Has anyone else run into this problem? Here's the page/control creation code:

            var pageId = Guid.NewGuid();
            var pageDataId = Guid.NewGuid();
            PageManager pageManager = PageManager.GetManager();
            pageManager.Provider.SuppressSecurityChecks = true
            PageData pageData = pageManager.CreatePageData();             pageData.HtmlTitle = pageName;             pageData.Title = pageName;             pageData.Template = pageManager.GetTemplates().Where(t => t.Title.Equals("DynamicLocation")).FirstOrDefault();              pageData.Status = ContentLifecycleStatus.Live;                            PageNode parent = pageManager.GetPageNode(SiteInitializer.FrontendRootNodeId);             PageNode pageNode = pageManager.CreatePage(parent, pageId, NodeType.Standard);             pageNode.Page = pageData;             pageNode.Name = pageName;             pageNode.Title = pageName;             pageNode.UrlName = Regex.Replace(pageUrl.ToLower(), UrlNameCharsToReplace, UrlNameReplaceString);             pageNode.ShowInNavigation = true;             pageNode.DateCreated = DateTime.UtcNow;             pageNode.LastModified = DateTime.UtcNow;             pageManager.RecompileItemUrls<PageNode>(pageNode);
            PageNode homePageNode = pageManager.GetPageNodes().Where(n => n.Title.Equals(parentCategory)).FirstOrDefault();
            pageManager.ChangeParent(pageNode, homePageNode);
            var draft = pageManager.EditPage(pageData.Id, true);

            PageDraftControl ctrl1 = pageManager.CreateControl<PageDraftControl>("~/App_widgets/Locations/LocationTitle.ascx""Location Title Content placeholder");
            ctrl1.PlaceHolder = "page_title";
            ctrl1.Caption = "Location Title";
            PageDraftControl ctrl2 = pageManager.CreateControl<PageDraftControl>();
            ctrl2.ObjectType = typeof(ContentBlock).FullName;
            ctrl2.PlaceHolder = "middle_content";
            ctrl2.Caption = "Location Description Content Block";
            ctrl2.Description = "Location description";
            PageDraftControl ctrl3 = pageManager.CreateControl<PageDraftControl>("~/App_widgets/Services/ServiceList.ascx""Service List Content placeholder");
            ctrl3.PlaceHolder = "services_list";
            ctrl3.Caption = "Service List";
                          pageManager.PublishPageDraft(draft, truenull);             pageManager.SaveChanges();
Thanks, Wendy

Posted by Community Admin on 04-Nov-2011 00:00

I figured out the issue. I had to add the following to each control:


I'm not sure if this is the best method, i.e. if I was missing an overarching permissions setting somewhere, but this resolved the issue.

This thread is closed