Copied to clipboard

Flag this post as spam?

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


  • Levente Kosa 136 posts 352 karma points
    Jun 21, 2015 @ 19:12
    Levente Kosa
    0

    News Archive

    Hi, I would like to implement a news archive function. At the moment I just have a News page with a lot of Article children. I would like to create a list with years and months, and when I click one of them the url changes somehow. The news page should shows the articles of the actual months always, and clicking the list I would get a different result. Also I need to know how many articles do I have at that year, month. Here is the stcructure:

    • 2015 (85)
      • Dec (22)
      • Nov (14)
      • Oct (3)
      • ...
    • 2014 (101)
    • 2013 (93)

    Unfortunately I have no idea, how can I start. Can you give me some advice or links, maybe code? I would really appreciate it. Thanks, L

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 21, 2015 @ 19:47
    Dennis Aaen
    0

    Hi Levente.

    Perhaps you can solve your case by using the uDateFoldersy package by Anthony Dang

    https://our.umbraco.org/projects/backoffice-extensions/udatefoldersy

    Hope this helps,

    /Dennis

  • Levente Kosa 136 posts 352 karma points
    Jun 21, 2015 @ 20:56
    Levente Kosa
    0

    Hi Dennis,

    Thanks, I'm gonna check it. Is that a standalone package, or do I need to install uBlogsy package as well? Is that following the structure with url or that is a different problem?

    Levente

  • Levente Kosa 136 posts 352 karma points
    Jun 21, 2015 @ 21:33
    Levente Kosa
    0

    Hi Dennis,

    I tried this package. I set up the config using my news page alias like root node. I set up the children alias as well, but when I tried to create a new page, I got two js error:

    POST http://localhost:57643/umbraco/backoffice/UmbracoApi/Content/PostSave 500 (Internal Server Error)
    TypeError: data.indexOf is not a function
    

    Have you ever met with this error?

  • Levente Kosa 136 posts 352 karma points
    Jun 26, 2015 @ 07:14
    Levente Kosa
    0

    Hi Dennis,

    Finally it's working without error message. I can create now folders automatically. Do you have any code example to show the archive list?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 27, 2015 @ 15:04
    Dennis Aaen
    100

    Hi Levente,

    Now I had the time to create a good starting point for you. This code below should create what you are after.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    
    @{ 
        var selection = CurrentPage.uDateFoldersyFolderYear.Where("Visible"); 
    }
    
    @if (selection.Any())
    {
        <ul>
            @foreach (var item in selection)
            {
    
                var newsItems = item.Descendants("umbNewsItem").Where("Visible");
                var month = item.Descendants("uDateFoldersyFolderMonth").Where("Visible");
                <li>
                    <a href="@item.Url">@item.Name</a> (@newsItems.Count())
                    <ul>
                    @foreach(var newsitem in month){ 
    
                        var countNewsItems = newsitem.Children.Where("Visible");
    
                        <li>
                             <a href="@newsitem.Url">@newsitem.Name</a> (@countNewsItems.Count())
                        </li>
                    }
                    </ul>   
                </li>
    
            }
        </ul>
    }
    

    Just remember to change the document type aliases so they are matching your case. In my example I have used a Partial view macro file, but you cn use the same code in a Partial view.

    The only difference is the inherits linie, it should be changed from

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    

    To

    @inherits UmbracoTemplatePage
    

    Hope this helps,

    /Dennis

  • Levente Kosa 136 posts 352 karma points
    Jun 27, 2015 @ 19:02
    Levente Kosa
    0

    Hi Dennis,

    Thank you so much your help. I really appreciate it. Do you know how can I use original create date instead of a custom one? I wouldn't have a problem with the custom field if it worked well, but when I make it required and I try to save the field blank, nothing happens.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 27, 2015 @ 19:32
    Dennis Aaen
    0

    Hi Levente.

    Yes you could use @CurrentPage.CreateDate, I have updated the whole code snippet so now I also output the create date. Hope this can give you some inspiration.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{ 
    
        var selection = CurrentPage.uDateFoldersyFolderYear.Where("Visible"); 
    
     }
    
    @if (selection.Any())
    
    {
        <ul>
    
            @foreach (var item in selection)
    
            {
                var newsItems = item.Descendants("umbNewsItem").Where("Visible");
    
                var month = item.Descendants("uDateFoldersyFolderMonth").Where("Visible");
    
                <li>
    
                    <a href="@item.Url">@item.Name</a> (@newsItems.Count()) @item.CreateDate
    
                    <ul>
    
                    @foreach(var newsitem in month){ 
    
                        var countNewsItems = newsitem.Children.Where("Visible");                    
    
                        <li>
    
                             <a href="@newsitem.Url">@newsitem.Name</a> (@countNewsItems.Count()) @newsitem.CreateDate
    
                        </li> 
    
                    }
    
                    </ul>   
    
                </li>
    
            }
    
        </ul>
    
    }
    

    Hope this helps,

    /Dennis

  • Levente Kosa 136 posts 352 karma points
    Jun 27, 2015 @ 20:12
    Levente Kosa
    0

    Hi Dennis,

    Sorry, I wasn't clear. I meant that I would like to use a createDate in uDateFordersy:

    <DatePropertyAlias>createDate</DatePropertyAlias>
    

    So when I save the node the folder will be the actual date. Unfortunately in this case I get PostSave error.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 27, 2015 @ 21:32
    Dennis Aaen
    0

    Hi Levente,

    Yes it looks like that you can use the create date to create the date for each news item. I have just tried to install the uBlogsy, that use the uDateFoldersy,

    And if I change the configuration to use

    <DatePropertyAlias>createDate</DatePropertyAlias>
    

    You can also do it with

    <DatePropertyAlias>CreateDate</DatePropertyAlias>
    

    Instead of the custom date field then I will get the value of 27, for todays date.

    /Dennis

  • Levente Kosa 136 posts 352 karma points
    Jun 27, 2015 @ 22:01
    Levente Kosa
    0

    Hi Dennis,

    Thanks, that is what I've already tried, but I got error. Probably something wrong with my system, what I can't see, or that I don't use uBlogsy, just the uDateFoldersy.

    Thank you for your help!

    L

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 28, 2015 @ 09:25
    Dennis Aaen
    0

    Hi Levente, I have just think about this over the night. Maybe this is the best solution to create custom property using the datetimepicker, to choose the "create date" of the news item.

    The reason for this is by using a custom property, then you can prepare some news items, and then set another publish date, than the date that the node was created in the back-end. Hope this helps, and make sense.

    /Dennis

  • Levente Kosa 136 posts 352 karma points
    Jun 28, 2015 @ 09:47
    Levente Kosa
    1

    Hi Dennis,

    Yes, this makes sense. Fortunately when I leave the datepicker field empty, the date going to be the current date, which is good for me.

    Thank you for your help and time again, I hope I didn't make you hard time.

Please Sign in or register to post replies

Write your reply to:

Draft