/// <summary> /// Process View if a Template has been set /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_PreRender(object sender, EventArgs e) { try { var isSharedModule = ModuleConfiguration.PortalID != ModuleConfiguration.OwnerPortalID; if (!isSharedModule) { var noTemplatesYet = !Sexy.GetVisibleTemplates(PortalId).Any(); // If there are no templates configured - show "getting started" frame if (noTemplatesYet && IsEditable && UserInfo.IsInRole(PortalSettings.AdministratorRoleName)) { pnlGetStarted.Visible = true; var gettingStartedControl = (GettingStartedFrame)LoadControl("~/DesktopModules/ToSIC_SexyContent/SexyContent/GettingStarted/GettingStartedFrame.ascx"); gettingStartedControl.ModuleID = this.ModuleId; gettingStartedControl.ModuleConfiguration = this.ModuleConfiguration; pnlGetStarted.Controls.Add(gettingStartedControl); } if (UserMayEditThisModule) { pnlTemplateChooser.Visible = true; } if (AppId.HasValue && !Sexy.PortalIsConfigured(Server, ControlPath)) { Sexy.ConfigurePortal(Server); } } if (AppId.HasValue) { if (Items.Any() && Template != null) { ProcessView(phOutput, pnlError, pnlMessage); } else if (!IsContentApp && UserMayEditThisModule) // Select first available template automatically if it's not set yet - then refresh page { var templates = Sexy.GetAvailableTemplatesForSelector(ModuleConfiguration).ToList(); if (templates.Any()) { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ModuleConfiguration.ModuleID), templates.First().TemplateID, UserInfo.UserID); } Response.Redirect(Request.RawUrl); } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void SetAppId(int?appId) { // Reset template to nothing (prevents errors after changing app) SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), null, UserInfo.UserID); SexyContent.SetAppIdForModule(ActiveModule, appId); // Change to 1. template if app has been set if (appId.HasValue) { var sexyForNewApp = new SexyContent(Sexy.App.ZoneId, appId.Value, false); var templates = sexyForNewApp.GetAvailableTemplatesForSelector(ActiveModule).ToList(); if (templates.Any()) { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), templates.First().TemplateID, UserInfo.UserID); } else { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), null, UserInfo.UserID); } } }
public void SaveTemplateId([FromUri] int?templateId) { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), templateId, UserInfo.UserID); }