コード例 #1
0
        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    if(!IsPostBack)
        //    {

        //    }
        //}

        protected string GetCustomControlToLoad()
        {
            string slug = RequestHelper.GetSlug();

            // Check for Page slugs
            //switch (storeContext.PageSlug)
            switch (slug)
            {
            case "Cart":
                return("Cart/Cart.ascx");

            case "LoginPrompt":
                return("Checkout/LoginPrompt.ascx");

            case "Checkout-Billing":
                return("Checkout/CheckoutBilling.ascx");

            case "Checkout-Shipping":
                return("Checkout/CheckoutShipping.ascx");

            case "Checkout-ShippingMethod":
                return("Checkout/CheckoutShippingMethod.ascx");

            case "Checkout-Payment":
                return("Checkout/CheckoutPayment.ascx");

            case "Checkout-Review":
                return("Checkout/CheckoutReview.ascx");

            case "Checkout-Complete":
                return("Checkout/CheckoutComplete.ascx");

            case "Catalog-Product":
                return("Catalog/CatalogProduct.ascx");
            }

            DataModel.Store currentStore = StoreContext.GetCurrentStore(Request);
            //if (storeContext.Product != null || WA.Parser.ToInt(Request.QueryString["product"]).HasValue)
            if (Product.SlugExists(currentStore.Id.Value, slug) || WA.Parser.ToInt(Request.QueryString["product"]).HasValue)
            {
                return("Catalog/CatalogProduct.ascx");
            }

            ////if (storeContext.Category != null)
            //if (!string.IsNullOrEmpty(categorySlug))
            //{
            //    return "Catalog/CatalogCategory.ascx";
            //}

            return("Catalog/CatalogCategory.ascx");
        }
コード例 #2
0
        public override void LoadSettings()
        {
            if (!IsPostBack)
            {
                DataModel.DataModel.Initialize();

                var store = StoreContext.GetCurrentStore(HttpContext.Current.Request);

                string sortByValue  = Convert.ToString(ModuleSettings[FeaturedSettings.SortBy]) ?? "Name-ASC";
                var    sortByFields = Product.GetSortByFields();
                ddlSortBy.Items.Clear();
                foreach (var f in sortByFields)
                {
                    ddlSortBy.Items.Add(new ListItem()
                    {
                        Value = f.GetValueString(), Text = f.DisplayName, Selected = f.GetValueString() == sortByValue
                    });
                }

                //txtProductsPerPage.Text = WA.Parser.ToInt(ModuleSettings[FeaturedSettings.ProductsPerPage]).GetValueOrDefault(100).ToString();
                txtMaxProducts.Text = WA.Parser.ToInt(ModuleSettings[FeaturedSettings.MaxNumProducts]).GetValueOrDefault(25).ToString();

                rdoCategoryFilterMethod.TrySetSelectedValue(Convert.ToString(ModuleSettings[FeaturedSettings.CategoryFilterMethod]));

                var allCategories       = CategoryCollection.GetCategoryList(store.Id.Value, true);
                var selectedCategoryIds = (Convert.ToString(ModuleSettings[FeaturedSettings.CategoryFilterCategoryIds]) ?? string.Empty).Split(',').Select(WA.Parser.ToInt).ToList();
                chkCategoryIds.Items.Clear();
                foreach (var cat in allCategories)
                {
                    string indent = "...".Repeat(cat.NestingLevel.GetValueOrDefault(0));
                    chkCategoryIds.Items.Add(new ListItem()
                    {
                        Value = cat.Id.Value.ToString(), Text = indent + cat.Name, Selected = selectedCategoryIds.Contains(cat.Id)
                    });
                }

                // Templates
                txtTemplateHeader.Text    = ModuleSettings[FeaturedSettings.TemplateHeader] != null ? ModuleSettings[FeaturedSettings.TemplateHeader].ToString() : FeaturedSettings.DefaultHeader;
                txtTemplateProduct.Text   = ModuleSettings[FeaturedSettings.TemplateProduct] != null ? ModuleSettings[FeaturedSettings.TemplateProduct].ToString() : FeaturedSettings.DefaultProduct;
                txtTemplateFooter.Text    = ModuleSettings[FeaturedSettings.TemplateFooter] != null ? ModuleSettings[FeaturedSettings.TemplateFooter].ToString() : FeaturedSettings.DefaultFooter;
                txtTemplateNoResults.Text = ModuleSettings[FeaturedSettings.TemplateNoResults] != null ? ModuleSettings[FeaturedSettings.TemplateNoResults].ToString() : FeaturedSettings.DefaultNoResults;
            }
        }