コード例 #1
0
        // GET: Blog/cat/{id}/{category}
        public ActionResult IndexCategory(int id, string category)
        {
            string section = "blog";
            string qString = "/blog";

            Language    language    = new Language("en-US");
            ContentPage contentPage = new ContentPage(qString);

            if (contentPage.PageID != Guid.Empty)
            {
                ViewData     = contentPage.GetSections();
                ViewBag.Meta = contentPage.MetaTags;

                MenuItem sideMenu = new MenuItem(Request.Url.AbsolutePath);
                ViewBag.SideMenu = sideMenu.SiblingMenuCode();

                ViewBag.Highlight = "$('." + section + "').addClass('active');";
            }

            ViewBag.BlogHeaderExt = "Blog Category: " + BlogPost.GetCategory(id);

            //Paging defaults
            int pg = 1;
            int sz = 20;

            //Retrieve / Store paging parameters
            if (Request.QueryString["pg"] != null)
            {
                if (!Int32.TryParse(Request.QueryString["pg"].ToString(), out pg))
                {
                    pg = 1;
                }
            }
            if (Request.QueryString["sz"] != null)
            {
                if (!Int32.TryParse(Request.QueryString["sz"].ToString(), out sz))
                {
                    sz = 20;
                }
            }

            BlogPosts       posts = new BlogPosts();
            List <BlogPost> blogs = posts.PostsInCategory(id, pg, sz);

            ViewBag.Pager = posts.CategoryPager(id, category, pg, sz);

            return(View("Index", blogs));
        }