예제 #1
0
        // GET: Blog/tag/{tag}
        public ActionResult IndexTag(string tag)
        {
            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 = "Blogs Tagged: " + tag;

            //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.PostsTagged(tag, pg, sz);

            ViewBag.Pager = posts.TagPager(tag, pg, sz);

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