Пример #1
0
        protected override void OnInit(EventArgs e)
        {
            int LayoutID = CommonLogic.QueryStringNativeInt("layoutid");

            ThisLayout = new LayoutData(LayoutID);

            if (ThisLayout != null)
            {
                bool exists = CommonLogic.FileExists(ThisLayout.LayoutFile);

                if (!exists)
                {
                    exists = ThisLayout.CreateLayoutControl();
                }

                if (exists)
                {
                    Control ctrl = LoadControl("layouts/" + ThisLayout.LayoutID.ToString() + "/" + ThisLayout.Name + "_" + ThisLayout.Version.ToString() + ".ascx");

                    pnlLayout.Controls.Add(ctrl);
                }
            }

            base.OnInit(e);
        }
Пример #2
0
        /// <summary>
        /// Overrides the OnPreRender method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            SetupMenu();

            if (AppLogic.AppConfigBool("Layouts.Enabled"))
            {
                bool HasMappedLayout = false;

                bool IsTopic   = (Page as SkinBase).IsTopicPage;
                bool IsEntity  = (Page as SkinBase).IsEntityPage;
                bool IsProduct = (Page as SkinBase).IsProductPage;

                int PageID = (Page as SkinBase).PageID;

                LayoutMap lm = new LayoutMap();

                if (IsEntity)
                {
                    String EntityType = (Page as SkinBase).EntityType;

                    lm = new LayoutMap(EntityType, PageID);

                    if (lm.LayoutID > 0)
                    {
                        HasMappedLayout = true;
                        (Page as SkinBase).ThisLayout = new LayoutData(lm.LayoutID);
                    }
                }
                else if (IsTopic)
                {
                    lm = new LayoutMap("topic", PageID);
                }
                else if (IsProduct)
                {
                    lm = new LayoutMap("product", PageID);
                }
                else
                {
                    String pName = CommonLogic.GetThisPageName(false);

                    lm = new LayoutMap(pName, PageID);
                }

                if (lm.LayoutID > 0)
                {
                    HasMappedLayout = true;
                    (Page as SkinBase).ThisLayout = new LayoutData(lm.LayoutID);
                }

                if (HasMappedLayout)
                {
                    LayoutData ThisLayout = (Page as SkinBase).ThisLayout;

                    if ((Page as SkinBase).ThisLayout != null)
                    {
                        bool exists = CommonLogic.FileExists(ThisLayout.LayoutFile);

                        if (!exists)
                        {
                            exists = ThisLayout.CreateLayoutControl();
                        }

                        if (exists)
                        {
                            Control ctrl = LoadControl("~/layouts/" + ThisLayout.LayoutID.ToString() + "/" + ThisLayout.Name + "_" + ThisLayout.Version.ToString() + ".ascx");

                            ContentPlaceHolder phContent = (ContentPlaceHolder)this.FindControl("PageContent");
                            phContent.Controls.Clear();

                            phContent.Controls.Add(ctrl);
                        }
                    }
                }
            }

            base.OnPreRender(e);
        }