Intrasite module - creating extra admin page

Posted by Community Admin on 05-Aug-2018 09:19

Intrasite module - creating extra admin page

All Replies

Posted by Community Admin on 17-Jun-2011 00:00

Just been following the blog post and have my main admin page in Modules/auctions/admin/admin.ascx which is created in mymodule.cs install routinue.  How can I add another page to this?  I thought it would be something like this:

var entryformsPage = pageManager.CreatePageData();
entryformsPage.Template = pageManager.GetTemplate(SiteInitializer.DefaultBackendTemplateId);
entryformsPage.HtmlTitle = "Entry Forms";
entryformsPage.Title = "Entry Forms";
entryformsPage.Status = ContentLifecycleStatus.Live;
entryformsPage.Visible = true;
entryformsPage.Version = 1;

But as i've already allocated node.Page to pagedata then added the control to pageData.Controls.Add, i'm unsure how you add this extra page.  Did a few searchs and looked at sdk but because it's intrasite it's layed out a bit differently.

Any ideas?

Thanks,
Chris

Posted by Community Admin on 17-Jun-2011 00:00

Actually it may not be 100% clear from that post i've just made - i think if i create multiple nodes it will be fine, if i want it as a subpage however that's what i'm refering to above.

Posted by Community Admin on 17-Jun-2011 00:00

Hello Chris,

You should create  a PageNode object. Each PageNode has a property Parent that sets the parent of the node being created.

sample

var pageNode = manager.CreatePageNode();
pageNode.Parent = manager.GetPageNode(SiteInitializer.FrontendRootNodeId);

All the best,
Ivan Dimitrov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Posted by Community Admin on 17-Jun-2011 00:00

Nearly got it think it's because the first item needs to be a group first.

Posted by Community Admin on 17-Jun-2011 00:00

Still struggling a bit because the example on www.sitefinity.com/.../creating_intra-site_modules_in_sitefinity_4.aspx doesn't call initializer.CratePageFromConfiguration so must be happening as it goes out of scope.  I've tried adding pageManager.SaveChanges(); but doesnt seem to create the backend page properly when creating that.

Tried the this way but it won't accept the page control:

            if (landingPage == null)
           
                var pageInfo = new PageDataElement()
               
                    PageId = this.LandingPageId,
                    Name = "Auctions",
                    MenuName = "Auctions",
                    UrlName = "auctions",
                    Description = "Auctions",
                    HtmlTitle = "Auctions",
                    IncludeScriptManager = true,
                    ShowInNavigation = true,
                    EnableViewState = true,
                    TemplateName = SiteInitializer.BackendTemplateName
                ;
                pageInfo.Parameters["ModuleName"] = AuctionsModule.ModuleName;
                var ctrl = pageManager.CreateControl<PageControl>("~/Modules/Auctions/Admin/AuctionsAdmin.ascx", "Content");
                //pageInfo.Controls.Add(ctrl);
                //initializer.CreatePageFromConfiguration(pageInfo, auctionsNode, controlPanel);
                initializer.CreatePageFromConfiguration(pageInfo, auctionsNode, ctrl);

           

Posted by Community Admin on 17-Jun-2011 00:00

Ummm i'm doing something basic wrong here any advice? When i go into backend pages get object null error.

var backendPagesNode = pageManager.GetPageNode(SiteInitializer.SitefinityNodeId);
 
var nodeAuctions = pageManager.CreatePageNode(this.LandingPageId);
nodeAuctions.NodeType = NodeType.Group;
nodeAuctions.Name = "Auctions";
nodeAuctions.Title = "Auctions";
nodeAuctions.UrlName = "auctions";
nodeAuctions.Description = "Auctions";
nodeAuctions.ShowInNavigation = true;
nodeAuctions.Attributes["ModuleName"] = AuctionsModule.ModuleName;
pageManager.ChangeParent(nodeAuctions, backendPagesNode);
backendPagesNode.Nodes.Add(nodeAuctions);
 
var nodeDashboard = pageManager.CreatePageNode(AuctionsPageDashboardId);
nodeDashboard.Parent = pageManager.GetPageNode(this.LandingPageId);
nodeDashboard.Name = "AuctionsDashboard";
nodeDashboard.Title = "Dashboard";
nodeDashboard.Description = "Auctions Dashboard";
nodeDashboard.ShowInNavigation = true;
nodeDashboard.Attributes["ModuleName"] = AuctionsModule.ModuleName;
 
var pageDataDashboard = pageManager.CreatePageData();
pageDataDashboard.Template = pageManager.GetTemplate(SiteInitializer.DefaultBackendTemplateId);
pageDataDashboard.HtmlTitle = "Dashboard";
pageDataDashboard.Title = "Dashboard";
pageDataDashboard.Status = ContentLifecycleStatus.Live;
pageDataDashboard.Visible = true;
pageDataDashboard.Version = 1;
 
nodeDashboard.Page = pageDataDashboard;
 
var ctrl = pageManager.CreateControl<PageControl>("~/Modules/Auctions/Admin/AuctionsAdmin.ascx", "Content");
pageDataDashboard.Controls.Add(ctrl);
 
backendPagesNode.Nodes.Add(nodeDashboard);


Thanks,
Chris

Posted by Community Admin on 20-Jun-2011 00:00

anyone?

Posted by Community Admin on 21-Jun-2011 00:00

Hi Chris,

For the "module" you want to create you only need one backend page and several child nodes for it. The way that backend pages are created is the same as the way that frontend pages are created. The only difference is the parent that is used for your "root" node and then you need to assign all child nodes to your parent.

Here is  sample code that will add a new group page and child page to Content menu

var staticID = new Guid("C70FF3BC-AE2A-4A53-A950-AADF06C6928D");
 
var parent = App.WorkWith().Pages().Where(root => root.Name == "Modules" && root.IsBackend == true).Get().SingleOrDefault();
var group1 = App.WorkWith().Page().CreateNewPageGroup(parent.Id, staticID).Do(gr =>
    gr.Name = "IntraModule";
    gr.Title = "IntraModule";
    gr.UrlName = "IntraModule";
).Done();
group1.CreateNewStandardPage(group1.Get().Id, Guid.NewGuid()).Do(pg =>
    pg.Name = "name";
    pg.Title = "title";
    pg.UrlName = "someurlname";
    pg.ShowInNavigation = true;
    pg.Page.Title = "datatitle";
    pg.Page.HtmlTitle = "htmldatatitle";
    pg.Description = "Some description";
)
.CheckOut()
.Publish()
.SaveChanges();

Since you don't have a real module with an Install method you should be able to create your pages as shown above in application_start of Global.asax

Greetings,
Ivan Dimitrov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

This thread is closed