Beispiel #1
0
        /// <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);
            }
        }
Beispiel #2
0
        public IEnumerable <object> GetSelectableTemplates()
        {
            var availableTemplates = Sexy.GetAvailableTemplatesForSelector(ActiveModule);

            return(availableTemplates.Select(t => new { t.TemplateID, t.Name, t.AttributeSetID }));
        }