Esempio n. 1
0
        protected LiquidTemplate CreateLiquidTemplate(string templateName, string page_title)
        {
            var template = new LiquidTemplate(MASTERdomain, (bool)Session[BrowserCapability.IsMobileSession]);
            template.InitLayoutTemplate("layout/theme.liquid");
            if (!string.IsNullOrEmpty(page_title))
            {
                template.AddParameters("page_title", page_title);
            }
            template.AddParameters("template", templateName);
            template.AddParameters("linklists", new LinkLists(MASTERdomain));
            template.AddParameters("pages", new Pages(MASTERdomain));
            template.AddParameters("blogs", new Blogs(MASTERdomain));
            template.AddParameters("collections", new Collections(MASTERdomain, sessionid));
            template.AddParameters("powered_by_link", "<a href='http://www.tradelr.com'>This online store is powered by tradelr</a>");

            // settings
            var settings_file = string.Format("{0}/{1}/config/settings_data.json", GeneralConstants.APP_ROOT_DIR, template.handler.GetThemeUrl());
            template.AddParameters("settings", template.ReadThemeSettings(settings_file));

            // cart
            var cartid = GetCartIdFromCookie();
            var liquidCart = new Cart();
            if (!string.IsNullOrEmpty(cartid))
            {
                var cart = MASTERdomain.carts.SingleOrDefault(x => x.id.ToString() == cartid);
                if (cart != null)
                {
                    if (cart.orderid.HasValue)
                    {
                        // cart already processed. clear cookie
                        Response.Cookies["cart"].Expires = DateTime.UtcNow.AddMonths(-1);
                    }
                    else
                    {
                        liquidCart = cart.ToLiquidModel(sessionid);
                    }
                }
            }
            template.AddParameters("cart", liquidCart);
            template.AddParameters("shop", MASTERdomain.ToLiquidModel());

            template.AddHeaderContent(MASTERdomain.metaTagVerification);

            // login panel
            template.AddParameters("login_for_store",
                                   this.RenderViewToString("~/Views/store/liquid/loginPanel.ascx",
                                                           new LoginPanel()
                                                               {
                                                                   isLoggedIn =sessionid.HasValue,
                                                                   hostName = accountHostname.ToDomainUrl()
                                                               }));
            // add filters
            // currency
            var currency = MASTERdomain.currency.ToCurrency();
            template.AddFilterValues("currency", currency);

            // add registers
            template.AddRegisters("current_url", Request.Url);

            // add term form date
            if (TempData["form"] != null)
            {
                template.AddParameters("posted_contact_form", TempData["form"]);
            }

            return template;
        }