Copied to clipboard

Flag this post as spam?

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


  • Craig 14 posts 34 karma points
    Jul 15, 2014 @ 12:29
    Craig
    0

    Modify Archive URL

    Hello,

    I’m working on a project to make the archive section of the website change the way it displays.

    I have converted the links to collate how many posts there are for a set date and to display the number in brackets.

    What I’m trying to achieve now is to make the link for the date not display the newest post, but to show a list with the title and summary for each post for that date.

    Now i have made a new if statement in "uBlogsyListPost.cshtml" to display the page how i want. But in the "uBlogsyListPostArchive.cshtml" file I have no idea how to make the link, link to say /news/posts/2014/june/ and then for that to link through to my new if statement in uBlogsyListPost template.

     

    I do hope this makes sense and someone could help.

    Thank you

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jul 15, 2014 @ 13:33
    Anthony Dang
    0

    So you want the archive to NOT show the actual articles.

    You want the month links to go to /news/posts/2014/june/

    Is that correct?

     

  • Craig 14 posts 34 karma points
    Jul 15, 2014 @ 13:59
    Craig
    0

    I would like it to display like this: http://www.beattiegroup.com/aboutour-pragency/prnews-m04-y2014.aspx

    on this website you can see that April has 2 posts. when you click the April button on the left, it displays the title and summary of those 2 posts.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jul 15, 2014 @ 14:49
    Anthony Dang
    0

    You basically want this:

     

    @for (index = 0; index < nodes.Count(); )
    {
        var node = nodes[index];
    
        var date = DateTime.Parse(node.GetValue("uBlogsyPostDate"));
        var currentYear = date.Year;
    
        if (firstYear == -1) { firstYear = currentYear; }
    
        var yearClass = "uBlogsy_year";
        if (currentYear == firstYear) { yearClass += " uBlogsy_year_first"; }
    
        // render years-months-items
        <li class="@yearClass"><a class="uBlogsy_year_name" href="#"><span>@currentYear</span></a>
            @*render year name*@
            <ul class="uBlogsy_months">
                @for (; index < nodes.Count(); index++)
                {
                    node = nodes[index];
                    date = DateTime.Parse(node.GetValue("uBlogsyPostDate"));
                    var currentMonth = date.Month;
    
                    if (date.Year != currentYear) { break; }
    
                    var monthLink = "/news/posts/"+ currentYear + "/" + currentMonth;
                    // render month
                    <li class="uBlogsy_month">
                        <a class="uBlogsy_month_name" href="@monthLink">
                            <span>@DateHelper.GetMonthName(currentMonth, false)</span>
                        </a>@*render month name*@
                    </li>
                }
            </ul>
        </li>
    }

     

     

     

     

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

    Thank for this code to make the link go to /news/posts/2014/june/ for example.

    But when i go to that url it shows the last post from that month.  How do i make it use my new tample layout where it will show a list of pages like the example link i gave before? I cant work out how to get the URL to know to use a different template. I see in the templates there is a Small="0" which means it will show the whole post or Small="1" which will show a list like Latest post does. But how do i make these links use a Small="2" for example which displays a list with titles and Summaries?


  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jul 15, 2014 @ 18:10
    Anthony Dang
    0

    you can probably just change the allowed templates of the month doctype to use the ublogsy landing template.

    And add this to the macroscript

     

     else if (@Parameter.Small == "2")
        {
    
            IEnumerable<DynamicNode> posts = Model.DescendantsOrSelf("uBlogsyPost");
    
    var postCount = posts.Count();
    // show each post foreach (DynamicNode n in nodes) { @RenderPage("/macroScripts/uBlogsy/uBlogsyShowPost.cshtml", n.Id) }
    }

     

     

  • Craig 14 posts 34 karma points
    Jul 16, 2014 @ 14:04
    Craig
    0

    How would uBlogsy know to use that when you click a link which looks like "/news/posts/2014/june/" that it doesnt go to the last post of that month but instead go to our new parameter of Small="2" and display it that way?

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jul 16, 2014 @ 15:33
    Anthony Dang
    0

    You need to change the template in the backoffice for the folder doctypes to just use the landing page template.

     

  • Craig 14 posts 34 karma points
    Jul 18, 2014 @ 12:34
    Craig
    0

    of course. Thank you so much.

  • Craig 14 posts 34 karma points
    Jul 24, 2014 @ 11:30
    Craig
    0

    Just incase anyone wants to see how i got this to work. This is the code for the page uBlogsyListPostArchive.cshtml. I then created a new template dedicated for the MonthFolder to change the look and feel of what would be shown.

    @for (int j = DateTime.Now.Year; j >= (DateTime.Now.Year - 5); j--)
                {
                    string yearClass = "uBlogsy_year";
    
                    var allpostforyearnumber = (from p in nodes
                                                 where p.GetPropertyValue("uBlogsyPostDate") != String.Empty &&
                                                 DateTime.Parse(p.GetPropertyValue("uBlogsyPostDate")).Year == j
                                                 select p.GetPropertyValue("uBlogsyPostDate")).ToList();
    
                    if (allpostforyearnumber.Count > 0)
                    {
                        // render years-months-items
                        <li class="@yearClass">
                            <a class="uBlogsy_year_name second-level-link" href="#">@j.ToString()</a> @*render year name*@
                            <ul class="uBlogsy_months nav-drop-level-2">
                                @{
    
                                    //Loop around each month in a year
                                    for (int i = 12; i >= 1; i--)
                                    {
    
                                        //Get article count for that month
    
                                        var allpostformonthnumber = (from p in nodes
                                                                     where p.GetPropertyValue("uBlogsyPostDate") != String.Empty &&
                                                                           DateTime.Parse(p.GetPropertyValue("uBlogsyPostDate")).Month == i &&
                                                                           DateTime.Parse(p.GetPropertyValue("uBlogsyPostDate")).Year == j
                                                                     select p.GetPropertyValue("uBlogsyPostDate")).ToList();
    
                                        //If greater than zero show list item and display count
                                        if (allpostformonthnumber.Count > 0)
                                        {
                                            var urlText = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i) + " (" + allpostformonthnumber.Count.ToString() + ")";
                                            var monthLink = "/news/posts/" + j.ToString() + "/" + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i);
                                            <li class="uBlogsy_month">
                                                <a class="uBlogsy_month_name third-level-link" href="@monthLink">@urlText</a>@*render month name*@    
    
                                            </li>
                                        }
                                    }
                                }
                            </ul>
                        </li>
                    }
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft