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
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?
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:
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
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.
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>
}
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.
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.
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.
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:
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
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
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
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:
Have you ever met with this error?
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?
Hi Levente,
Now I had the time to create a good starting point for you. This code below should create what you are after.
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
To
Hope this helps,
/Dennis
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.
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.
Hope this helps,
/Dennis
Hi Dennis,
Sorry, I wasn't clear. I meant that I would like to use a createDate in uDateFordersy:
So when I save the node the folder will be the actual date. Unfortunately in this case I get PostSave error.
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
You can also do it with
Instead of the custom date field then I will get the value of 27, for todays date.
/Dennis
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
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
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.
is working on a reply...