Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bobi 352 posts 956 karma points
    Mar 21, 2017 @ 19:39
    Bobi
    0

    Show all blog posts

    How would you show all blog posts on the main page of the blog? I was thinking something like adding the partial pager model to the recent.cshtml in Articulate, but I am having trouble doing this.

    I have the pager working with search results, but I can't get it to work with recent.cshtml. If you have 30 results, then say, after 10, then you'd have 3 pages.

    Essentially I am looking to make my Recent.cshtml page to show all blog posts with the addition of the pager, and be the default page that users land on when they go to the blog link.

    My List.cshtml looks like this:

    @using Articulate
    @using Articulate.Models
    @using ClientDependency.Core.Mvc
    @using Umbraco.Core
    @using Umbraco.Web
    @using Umbraco.Web.Models
    @inherits UmbracoViewPage<ListModel>
    @{
    Layout = "Master.cshtml";
    
    }
    
    @*Render different content if it's the homepage*@
    @if (Model.DocumentTypeAlias == "ArticulateArchive")
    {
    
    @Html.ThemedPartial(Model, "Recent")
    
    }
    else
    {
    
    if (!Model.Children.Any())
    {
    
        if (!Request.QueryString["term"].IsNullOrWhiteSpace())
        {
    
            <!-- Left Sidebar -->
            <div class="col-md-9 md-margin-bottom-40">
                <!--Blog Post-->
                <div class="blog margin-bottom-40">
                    @*<h2>Search Results</h2><br /><br />*@
    
                    <p class="lead">No articles found for search term <strong>@Request.QueryString["term"]</strong>.</p>
    
                </div>
                <!--End Blog Post-->
                <hr>
    
            </div>
            <!-- End Left Sidebar -->
        }
    
    }
    else
    {
        if (Request.QueryString["term"] == "")
        {
    
            <!-- Left Sidebar -->
            <div class="col-md-9 md-margin-bottom-40">
                <!--Blog Post-->
                <div class="blog margin-bottom-40">
                    @*<h2>Search Results</h2><br /><br />*@
    
                    <p class="lead">Please enter search criteria.</p>
    
                </div>
                <!--End Blog Post-->
                <hr>
    
            </div>
            <!-- End Left Sidebar -->
        }
        else
        {
            <!-- Left Sidebar -->
            <div class="col-md-9 md-margin-bottom-40">
    
                    @{     
    
    
                    var categoryPath = "/articles/categories/";
                    var tagPath = "/articles/tags/";
    
    
                    }
    
                    @if (Model.Pages.TotalPages > 1)
                    {
    
                        if (!Request.QueryString["term"].IsNullOrWhiteSpace())
                        {
                            <p class="lead">Your search for <strong>@Request.QueryString["term"]</strong> matched <strong>@Model.Pages.TotalPages</strong> results.</p>
                            <p class="lead">Showing results <strong>@Model.Pages.TotalPages</strong> to <strong>@Model.Pages.TotalPages</strong>.</p>
                        }
    
                        else if (Request.Path.Contains(categoryPath))
                        {
                            <p class="lead">Your search for <strong>@Request.Path.Remove(0, 21)</strong> matched <strong>@Model.Pages.TotalPages</strong> results.</p>
                            <p class="lead">Showing results <strong>@Model.Pages.TotalPages</strong> to <strong>@Model.Pages.TotalPages</strong>.</p>
                        }
    
                        else if (Request.Path.Contains(tagPath))
                        {
                            <p class="lead">Your search for <strong>@Request.Path.Remove(0, 15)</strong> matched <strong>@Model.Pages.TotalPages</strong> results.</p>
                            <p class="lead">Showing results <strong>@Model.Pages.TotalPages</strong> to <strong>@Model.Pages.TotalPages</strong>.</p>
                        }
    
                    }
                    else
                    {
                        if (!Request.QueryString["term"].IsNullOrWhiteSpace())
                        {
                            <p class="lead">Your search for <strong>@Request.QueryString["term"]</strong> matched <strong>@Model.Pages.TotalPages</strong> result.</p>
                            <p class="lead">Showing results <strong>@Model.Pages.TotalPages</strong> to <strong>@Model.Pages.TotalPages</strong>.</p>
                        }
    
                        else if (Request.Path.Contains(categoryPath))
                        {
                            <p class="lead">Your search for <strong>@Request.Path.Remove(0, 21)</strong> matched <strong>@Model.Pages.TotalPages</strong> result.</p>
                            <p class="lead">Showing results <strong>@Model.Pages.TotalPages</strong> to <strong>@Model.Pages.TotalPages</strong>.</p>
                        }
    
                        else if (Request.Path.Contains(tagPath))
                        {
                            <p class="lead">Your search for <strong>@Request.Path.Remove(0, 15)</strong> matched <strong>@Model.Pages.TotalPages</strong> result.</p>
                            <p class="lead">Showing results <strong>@Model.Pages.TotalPages</strong> to <strong>@Model.Pages.TotalPages</strong>.</p>
                        }
                    }
    
                    @foreach (var post in Model.Children<PostModel>
                                                ())
                    {
                        @Html.ThemedPartial(Model, "PostSearch", post, new ViewDataDictionary { { "IsListView", true } })<br /><br />
                    }
    
    
    
                    @Html.ThemedPartial(Model, "Pager", Model.Pages)
    
    
    
            </div>
            <!-- End Left Sidebar -->
    
                                }
    
                            }
    
                        }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

    Continue discussion

Please Sign in or register to post replies