Ejemplo n.º 1
0
        public override void Render(Context context, TextWriter result)
        {
            var mutablePagedList = context[_collectionName] as IMutablePagedList;
            var collection = context[_collectionName] as ICollection;
            var pagedList = context[_collectionName] as IPagedList;
            Uri requestUrl;
            Uri.TryCreate(context["request_url"] as string, UriKind.RelativeOrAbsolute, out requestUrl);
            var pageNumber = (int)context["current_page"];
 
            if (mutablePagedList != null)
            {
                mutablePagedList.Slice(pageNumber, _pageSize > 0 ? _pageSize : 20);
                pagedList = mutablePagedList;
            }
            else if (collection != null)
            {
                pagedList = new PagedList<Drop>(collection.OfType<Drop>().AsQueryable(), pageNumber, _pageSize);                
                //TODO: Need find way to replace ICollection instance in liquid context to paged instance
                //var hash = context.Environments.FirstOrDefault(s => s.ContainsKey(_collectionName));
                //hash[_collectionName] = pagedList;
            }

            if (pagedList != null)
            {
                var paginate = new Paginate(pagedList);
                context["paginate"] = paginate;

                for (int i = 1; i <= pagedList.PageCount; i++)
                {
                    paginate.Parts.Add(new Part { IsLink = i != pagedList.PageNumber, Title = i.ToString(), Url = requestUrl != null ? requestUrl.SetQueryParameter("page", i.ToString()).ToString() : i.ToString() });
                }
                RenderAll(NodeList, context, result);
            }
        }
Ejemplo n.º 2
0
        public override void Render(Context context, TextWriter result)
        {
            var pagedList = context[_collectionName] as IStorefrontPagedList;
            if (pagedList == null)
            {
                return;
            }

            var themeEngine = (ShopifyLiquidThemeEngine)Template.FileSystem;
            var workContext = themeEngine.WorkContext;

            var paginate = new Paginate(pagedList);
            context["paginate"] = paginate;

            for (int i = 1; i <= pagedList.PageCount; i++)
            {
                paginate.Parts.Add(new Part { IsLink = i != pagedList.PageNumber, Title = i.ToString(), Url = pagedList.GetPageUrl(i) });
            }
            RenderAll(NodeList, context, result);
        }