示例#1
0
        public ActionResult Index(RenderModel model, int?p)
        {
            //create a master model
            var masterModel = new MasterModel(model.Content);

            var listNodes = masterModel.RootBlogNode.Children("ArticulateArchive").ToArray();

            if (listNodes.Length == 0)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            var totalPosts = Umbraco.GetPostCount(model.Content.Name, listNodes.Select(x => x.Id).ToArray());

            PagerModel pager;

            if (!GetPagerModel(masterModel, totalPosts, p, out pager))
            {
                return(new RedirectToUmbracoPageResult(model.Content.Parent, UmbracoContext));
            }

            var authorPosts = Umbraco.GetContentByAuthor(listNodes, model.Content.Name, pager);
            var author      = new AuthorModel(model.Content, authorPosts, pager, totalPosts);

            return(View(PathHelper.GetThemeViewPath(author, "Author"), author));
        }
示例#2
0
        private ActionResult RenderView(IRenderModel model, int?p = null)
        {
            var listNodes = model.Content.Children("ArticulateArchive").ToArray();

            if (listNodes.Length == 0)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            var master = new MasterModel(model.Content);

            //Get post count by xpath is much faster than iterating all children to get a count
            var count = Umbraco.GetPostCount(listNodes.Select(x => x.Id).ToArray());

            return(GetPagedListView(master, listNodes[0], listNodes[0].Children, count, p));
        }
        private ActionResult RenderView(IRenderModel model, int?p = null)
        {
            var listNode = model.Content.Children
                           .FirstOrDefault(x => x.DocumentTypeAlias.InvariantEquals("ArticulateArchive"));

            if (listNode == null)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            if (p != null && p.Value == 1)
            {
                return(new RedirectToUmbracoPageResult(model.Content, UmbracoContext));
            }

            if (p == null || p.Value <= 0)
            {
                p = 1;
            }

            var rootPageModel = new MasterModel(model.Content);

            //get the count with XPath, this will be the fastest
            var totalPosts = Umbraco.GetPostCount(listNode.Id);

            var pageSize   = rootPageModel.PageSize;
            var totalPages = Convert.ToInt32(Math.Ceiling((double)totalPosts / pageSize));

            //Invalid page, redirect without pages
            if (totalPages > 0 && totalPages < p)
            {
                return(new RedirectToUmbracoPageResult(model.Content, UmbracoContext));
            }

            var pager = new PagerModel(
                pageSize,
                p.Value - 1,
                totalPages,
                totalPages > p ? model.Content.Url.EnsureEndsWith('?') + "p=" + (p + 1) : null,
                p > 2 ? model.Content.Url.EnsureEndsWith('?') + "p=" + (p - 1) : p > 1 ? model.Content.Url : null);

            var listItems = Umbraco.GetPostsSortedByPublishedDate(listNode.Id, pager);

            var listModel = new ListModel(listNode, listItems, pager);

            return(View(PathHelper.GetThemeViewPath(listModel, "List"), listModel));
        }
        private ActionResult RenderView(ContentModel model, int?p = null)
        {
            var listNodes = model.Content.ChildrenOfType("ArticulateArchive").ToArray();

            if (listNodes.Length == 0)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            var master = new MasterModel(model.Content);

            var count = Umbraco.GetPostCount(listNodes.Select(x => x.Id).ToArray());

            var posts = Umbraco.GetRecentPosts(master, p ?? 1, master.PageSize);

            return(GetPagedListView(master, listNodes[0], posts, count, p));
        }
示例#5
0
        public ActionResult GetPosts(int id, int page)
        {
            var content = Umbraco.TypedContent(id);

            var master = new MasterModel(content);

            var count = Umbraco.GetPostCount(id);

            var posts = Umbraco.GetRecentPosts(master, page, master.PageSize);

            var viewPath = PathHelper.GetThemePartialViewPath(master, "ListPost");

            var html = string.Empty;

            foreach (var post in posts)
            {
                html += RenderViewToString(this, viewPath, post, true);
            }

            return(Content(html));
        }
示例#6
0
        private ActionResult RenderView(IContentModel model, int?p = null)
        {
            var archive = new MasterModel(model.Content);

            // redirect to root node when "redirectArchive" is configured
            if (archive.RootBlogNode.Value <bool>("redirectArchive"))
            {
                return(RedirectPermanent(archive.RootBlogNode.Url));
            }

            //Get post count by xpath is much faster than iterating all children to get a count
            var count = Umbraco.GetPostCount(archive.Id);

            int pageSize;

            if (!Int32.TryParse(archive.RootBlogNode.Value <string>("pageSize"), out pageSize))
            {
                pageSize = 10;
            }

            var posts = Umbraco.GetRecentPostsByArchive(archive, 1, pageSize);

            return(GetPagedListView(archive, archive, posts, count, null));
        }