/// <summary> /// Adds the "Add a new job" menu item to the Edit Menu. /// </summary> /// <param name="pageToAddCommandTo"></param> /// <param name="jobAggregatorPage"></param> public static void AddJobPostingCommandToEditMenu(CmsPage pageToAddCommandTo, CmsPage jobAggregatorPage) { // -- only add the command if the user can author if (!pageToAddCommandTo.currentUserCanWrite) { return; } // -- base the command off the existing "create new sub-page" command CmsPageEditMenuAction createNewSubPage = pageToAddCommandTo.EditMenu.getActionItem(CmsEditMenuActionItem.CreateNewPage); if (createNewSubPage == null) { throw new Exception("Fatal Error in in JobPostingAggregator placeholder - could not get the existing CreateNewPage action"); } CmsPageEditMenuAction CreateNewJobMenuAction = createNewSubPage.Copy(); // copy everything from the CreateNewPage entry // -- configure this command to not prompt authors for any information. // the minimum information needed to create a page is the new page's filename (page.name) // -- get the next unique filename string newPageName = ""; for (int jobNum = 1; jobNum < int.MaxValue; jobNum++) { string pageNameToTest = "Job " + jobNum.ToString(); if (!CmsContext.childPageWithNameExists(jobAggregatorPage.Id, pageNameToTest)) { newPageName = pageNameToTest; break; } } string newPageTitle = ""; string newPageMenuTitle = ""; string newPageSearchEngineDescription = ""; bool newPageShowInMenu = false; string newPageTemplate = CmsConfig.getConfigValue("JobPosting.DetailsTemplateName", "_JobPosting"); CreateNewJobMenuAction.CreateNewPageOptions = CmsCreateNewPageOptions.GetInstanceWithNoUserPrompts(newPageName, newPageTitle, newPageMenuTitle, newPageSearchEngineDescription, newPageShowInMenu, newPageTemplate, jobAggregatorPage.Id); CreateNewJobMenuAction.CreateNewPageOptions.ParentPageId = jobAggregatorPage.Id; CreateNewJobMenuAction.SortOrdinal = createNewSubPage.SortOrdinal + 1; CreateNewJobMenuAction.doRenderToString = AddJobPostingEditMenuRender; pageToAddCommandTo.EditMenu.addCustomActionItem(CreateNewJobMenuAction); }
/// <summary> /// Adds the "Add an image gallery" menu item to the Edit Menu. /// </summary> /// <param name="pageToAddCommandTo"></param> /// <param name="userImageGalleryAggregator"></param> public static void AddGalleryCommandToEditMenu(CmsPage pageToAddCommandTo, CmsPage userImageGalleryAggregator) { // -- only add the command if the user can author if (!pageToAddCommandTo.currentUserCanWrite) { return; } // -- base the command off the existing "create new sub-page" command CmsPageEditMenuAction createNewSubPage = pageToAddCommandTo.EditMenu.getActionItem(CmsEditMenuActionItem.CreateNewPage); if (createNewSubPage == null) { return; } CmsPageEditMenuAction newAction = createNewSubPage.Copy(); // copy everything from the CreateNewPage entry // -- configure this command to not prompt authors for any information. // the minimum information needed to create a page is the new page's filename (page.name) // -- get the next unique filename string newPageName = ""; for (int eventNum = 1; eventNum < int.MaxValue; eventNum++) { string pageNameToTest = "Gallery" + eventNum.ToString(); if (!CmsContext.childPageWithNameExists(userImageGalleryAggregator.ID, pageNameToTest)) { newPageName = pageNameToTest; break; } } string newPageTitle = ""; string newPageMenuTitle = ""; string newPageSearchEngineDescription = ""; bool newPageShowInMenu = true; string newPageTemplate = CmsConfig.getConfigValue("UserImageGallery.DetailsTemplateName", "UserImageGallery"); newAction.CreateNewPageOptions = CmsCreateNewPageOptions.GetInstanceWithNoUserPrompts(newPageName, newPageTitle, newPageMenuTitle, newPageSearchEngineDescription, newPageShowInMenu, newPageTemplate, userImageGalleryAggregator.ID); newAction.CreateNewPageOptions.ParentPageId = userImageGalleryAggregator.ID; newAction.SortOrdinal = createNewSubPage.SortOrdinal + 1; newAction.doRenderToString = AddGalleryEditMenuRender; pageToAddCommandTo.EditMenu.addCustomActionItem(newAction); }