Copied to clipboard

Flag this post as spam?

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


  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 01, 2019 @ 05:19
    Emmanuel Ramanyimi
    0

    How can i list 5 articles currently now i can view 3 below is the code i have don

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using ClientDependency.Core.Mvc; @using System.Web.Mvc; @using System.Web.Mvc.Html; @using Umbraco.Core.Models; @using System.Linq; @{ Layout = "WebPage.cshtml"; ViewBag.footertype = "skew";

    int pageSize = 10;
    int page = 1;
    if (!String.IsNullOrEmpty(Request.QueryString["p"]))
    {
        try
        {
            page = int.Parse(Request.QueryString["p"]);
        }
        catch (Exception ex)
        {
            page = 1;
        }
    }
    
    IPublishedContent ArticleSection = Model.Content.AncestorOrSelf(2).DescendantsOrSelf("ArticleList").SingleOrDefault();
    IEnumerable<IPublishedContent> AllArticles = ArticleSection.Children.Where(x => x.IsVisible()).ToList();
    IEnumerable<IPublishedContent> FilteredArticles = AllArticles; 
    int count = FilteredArticles.Count();
    if (Model.Content.DocumentTypeAlias == "ArticleCategory")
    {
    

    FilteredArticles = FilteredArticles.Where(x => x.GetPropertyValue<>

    @foreach (IPublishedContent post in FilteredArticles.OrderByDescending(x => x.GetPropertyValue
                    <div class="row">
                        @Html.Partial("blog/Pager", Model.Content, new ViewDataDictionary { { "count", count }, { "pageSize", pageSize } }) 
    
                    </div>
    
                </div>
    
            </div>
        </div>
    </section>
    

    }

  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 01, 2019 @ 05:26
    Emmanuel Ramanyimi
    0

    enter image description here

    On arrow for previous and next current i can only view 3 article i would like to be able to view at least more than 5 article.

    Please help

  • Dirk Seefeld 126 posts 665 karma points
    Jun 02, 2019 @ 10:42
    Dirk Seefeld
    0

    Hi Emmanuel, seems the critical part is not visible due to copy / paste issue with the blog engine. Struggled on my own with this;-)

    So, please send the following line again:

    FilteredArticles = FilteredArticles.Where(x => x.GetPropertyValue<>
    

    The issue must be cause in this line I think. Two things appear already strange to me:

    1. Why do you expect 5 items per page for a pageSize of 10?
    2. Why getting count before executing FilteredArticles = FilteredArticles.Where(... ?

    In general - I guess - you should use:

    var pageFilteredArticles = FilteredArticles.Skip(p * pageSize).Take(pageSize);
    @foreach(avr article in pageFilteredArticles) {...
    

    To get the articles per page.

    Yours Dirk

  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 03, 2019 @ 15:15
    Emmanuel Ramanyimi
    0

    var firstOrDefault = new ArticlePost(newsArticleList.FirstOrDefault()); var lastItem = new ArticlePost(newsArticleList.LastOrDefault());

    previous arrow and next arrow for view articles

  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 03, 2019 @ 15:16
    Emmanuel Ramanyimi
    0

      FilteredArticles = FilteredArticles.Where(x => x.GetPropertyValue<List<IPublishedContent>>("categories").Exists(element => element.Id == Model.Content.Id));
    
  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 03, 2019 @ 15:17
    Emmanuel Ramanyimi
    0
    @foreach (IPublishedContent post in FilteredArticles.<DateTime>(x => x.GetPropertyValue("publishedDate")).Skip(page * pageSize).Take(pageSize))
    
                            {
                                var categories = post.GetPropertyValue<IEnumerable<IPublishedContent>>("categories");
    
  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 02, 2019 @ 11:14
    Emmanuel Ramanyimi
    0

    Hi Dirk Seefeld

    Below is the line u have ask:

    FilteredArticles = FilteredArticles.Where(x => x.GetPropertyValue<>

  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 02, 2019 @ 11:19
    Emmanuel Ramanyimi
    0

    enter image description here

  • Emmanuel Ramanyimi 19 posts 90 karma points
    Jun 03, 2019 @ 13:57
    Emmanuel Ramanyimi
    0

    enter image description here

    previous arrow(is using method for FisrtOrDefault) Next Arrow( using method for LastOrDefault)

    if you clicks on arrow next it jumps articles and takes the 2 last article- I want this to open the next article

    if you clicks on arrow previous it jumps articles and takes the first article or recent article only- I want this to open the previous article

Please Sign in or register to post replies

Write your reply to:

Draft