Copied to clipboard

Flag this post as spam?

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


  • suzyb 474 posts 932 karma points
    Mar 13, 2012 @ 11:03
    suzyb
    0

    Modifying archive so it doesn't show individual posts

    Is it ppossible to modify the archive so it doesn't show the individual posts but instead clicking the month shows all the posts for that month.  This kind of layout

    2012
    -- January (2)
    -- February (3)

    where clicking the year hides or shows the list of months and clicking the month name shows the posts for that monthas a landing page.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 13, 2012 @ 11:07
    Anthony Dang
    0

    Yes you can do that.

    You'll have to modify the Archive script to not render the posts, and also modify the jquery at the top of the script to not bind to the click event.

    Then what you can do is create a new template for uBlogsyFolderMonth which renders children of the month node.

     

  • suzyb 474 posts 932 karma points
    Mar 13, 2012 @ 12:09
    suzyb
    0

    Is it possible to select the years and months using Linq instead of looping all the posts.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 13, 2012 @ 12:24
    Anthony Dang
    0

    Razor is just c#, and Umbraco is just .net so you can do anything you like.

    What exactly do you want to do with Linq?

     

     

     

  • suzyb 474 posts 932 karma points
    Mar 13, 2012 @ 12:40
    suzyb
    0

    tbh I'm not really sure.  I haven't done any razor or linq other than modifying a few of the uBlogsy files to alter the way the blog is displayed so not really sure what can be done.

    What I was thinking was selecting all the years from the list of nodes, sorted in descending order.  Then looping that list and within it selecting all the months that have posts in that year, again sorted in descending order.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 13, 2012 @ 12:49
    Anthony Dang
    0

    You could do that if you want:

    foreach (var yearFolder in (landing.Descendents("uBlogsyFolderYear")){

        foreach (var monthFolder in (yearFolder.Descendents("uBlogsyFolderMonth")){

            foreach (var post in (yearMonth.Descendents("uBlogsyPost")){       

                // .. do somethign

            }

        }

    }

     

     

  • suzyb 474 posts 932 karma points
    Mar 13, 2012 @ 16:57
    suzyb
    0

    Sometimes you can't see the easy solution for the hard one :(

    That worked. Thanks.

  • Craig 14 posts 34 karma points
    Jul 02, 2014 @ 10:17
    Craig
    0

    Hi Suzyb,

    I have been to your company website and see that you got your grouping of blog posts in the archive section sorted.

    Are you able to give examples of your code as i have been requested to do the same thing yet im looking through this post and not getting very far.

    Craig

     

  • suzyb 474 posts 932 karma points
    Jul 08, 2014 @ 12:31
    suzyb
    0

    Sorry, I didn't notice your post till now.  Here is the code we use in case it's still of some use.

    <ul class="uBlogsy_years">
    @foreach (dynamic yearItems in nodes.OrderByDescending(x => DateTime.Parse(x.GetProperty("uBlogsyPostDate").Value)))  
    {
    if (currentYear != yearItems.uBlogsyPostDate.Year)
        {
            currentMonth = -1;          // reset currentMonth so same month different years works
            currentYear = yearItems.uBlogsyPostDate.Year;
            <li class="uBlogsy_year">
                <a class="uBlogsy_year_name" href="@yearItems.AncestorOrSelf("uBlogsyFolderYear").Url"><span>@yearItems.uBlogsyPostDate.ToString("yyyy")</span></a>
                <ul class="uBlogsy_months">
                    @{
                        dynamic monthNodes = ((IEnumerable<DynamicNode>)nodes
                            .Where(x => DateTime.Parse(x.GetProperty("uBlogsyPostDate").Value).Year == yearItems.uBlogsyPostDate.Year)
                            .OrderByDescending(x => DateTime.Parse(x.GetProperty("uBlogsyPostDate").Value)).ToList());
    
                        foreach (dynamic monthItems in monthNodes)
                        {                           
                            if (currentMonth != monthItems.uBlogsyPostDate.Month)
                            {
                                currentMonth = monthItems.uBlogsyPostDate.Month;
    
                                int countPosts = ((IEnumerable<DynamicNode>)nodes
                                    .Where(x => DateTime.Parse(x.GetProperty("uBlogsyPostDate").Value).Year == monthItems.uBlogsyPostDate.Year)
                                    .Where(x => DateTime.Parse(x.GetProperty("uBlogsyPostDate").Value).Month == monthItems.uBlogsyPostDate.Month)
                                    .ToList()).Count();
    
                                    <li class="uBlogsy_month">                                                
                                       <a class="uBlogsy_month_name" href="@monthItems.Parent.Url"> <span>@monthItems.uBlogsyPostDate.ToString("MMMM") (@countPosts)</span> </a>
                                    </li>                                            
                            }                                        
                        }
                    }
                </ul>                            
            </li>                                              
        }                    
    }
    </ul>
  • Craig 14 posts 34 karma points
    Jul 14, 2014 @ 12:19
    Craig
    0

    Its perfectly fine. Thank you for getting back to me.

    Its good to see how you made it work.

    I notice that your links of your months use a custom link. Have you made a new "uBlogsyShowPost" section, or did you make a new template to show the list of posts for the selected month?

  • suzyb 474 posts 932 karma points
    Jul 15, 2014 @ 10:54
    suzyb
    0

    IIRC we modified the post listing so we could list by month.

  • Craig 14 posts 34 karma points
    Jul 15, 2014 @ 10:56
    Craig
    0

    Awesome, thank you so much for your help. Massively appreciate it.

Please Sign in or register to post replies

Write your reply to:

Draft