Copied to clipboard

Flag this post as spam?

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


  • Biagio Paruolo 1618 posts 1910 karma points c-trib
    Apr 18, 2013 @ 15:07
    Biagio Paruolo
    0

    How to display posts from some categories

    This is my workaround:

    var tuttiposts = new List<DynamicNode>();

    var nodescategories = PostService.Instance.GetPosts(Model.Id);

            foreach (var n in nodescategories)

            {

                allCategories.AddRange(n.uBlogsyPostCategories.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));

            }

            // get only distinct categories

            IEnumerable<string> elencocategorie = allCategories.Distinct();          

            if (elencocategorie.Count() > 0){                 

                        foreach (var c in elencocategorie)

                        {

                            if ((!string.IsNullOrEmpty(c.Trim())) && (c!="News"))

                            {

                              var posts1 = PostService.Instance.GetPosts(Model.Id, tag, c, author, searchTerm, commenter, page-1, count);

         tuttiposts.AddRange(posts1);  

                            }

                        }

              }

     var orderedposts = tuttiposts.OrderByDescending(x => x.GetPropertyValue("uBlogsyPostDate")).Distinct().Take(count);

       @foreach (DynamicNode n in orderedposts)   

            {

             ...........

             }

Please Sign in or register to post replies

Write your reply to:

Draft