I have a list of Contents with Document Type having on of the property as Date Picker, I would like to display the contents grouped together by Month,Year. Could any one please let me know a way to do this using Razor script.
I have a Document type with Data type as DatePicker as a start date(Like an Event). The document type has additional properties like Title, Image, Description etc.. I need to list out those based on Month and Year. current Month + 5 Months.
First thing I think I need to Get the Informaton in a list like this
August 2011 Item1Title ItemDesc ItemImage August 2011 Item2Title ItemDesc ItemImage September 2011 Item1Title ItemDesc ItemImage September 2011 Item2Title ItemDesc ItemImage October 2011 Item1Title ItemDesc ItemImage October 2011 Item2Title ItemDesc ItemImage
Then I will list that under
August 2011 Item1..... Item2.....
September 2011 Item1.... Item2.... Octpber 2011 Item1.... Item2....
I am facing some problems with manipulating datepicker value in Razor like we do in LINQ or SQL.
OK, I can at least help you with the first part, which is the initial listing for the next 5 months. Assuming your event date property is called DisplayDate then you could do this:
The second part is more tricky. The way I would have done it in using standard LINQ queries doesn't work with Umbraco. If I get some time I'll have a think and see if there's another way that does work.
Group by Month and Year
I have a list of Contents with Document Type having on of the property as Date Picker, I would like to display the contents grouped together by Month,Year. Could any one please let me know a way to do this using Razor script.
Appreciate your inputs.
-Rajeev
Could you give an example of the output you would like to see?
Hi Dan,
I have a Document type with Data type as DatePicker as a start date(Like an Event).
The document type has additional properties like Title, Image, Description etc..
I need to list out those based on Month and Year. current Month + 5 Months.
First thing I think I need to Get the Informaton in a list like this
August 2011 Item1Title ItemDesc ItemImage
August 2011 Item2Title ItemDesc ItemImage
September 2011 Item1Title ItemDesc ItemImage
September 2011 Item2Title ItemDesc ItemImage
October 2011 Item1Title ItemDesc ItemImage
October 2011 Item2Title ItemDesc ItemImage
Then I will list that under
August 2011
Item1.....
Item2.....
September 2011
Item1....
Item2....
Octpber 2011
Item1....
Item2....
I am facing some problems with manipulating datepicker value in Razor like we do in LINQ or SQL.
Hope the question is clear now.
Appreciate your help.
Thanks,
Rajeev
Hi Rajeev,
OK, I can at least help you with the first part, which is the initial listing for the next 5 months. Assuming your event date property is called DisplayDate then you could do this:
The second part is more tricky. The way I would have done it in using standard LINQ queries doesn't work with Umbraco. If I get some time I'll have a think and see if there's another way that does work.
Hi Dan,
Thank you for the reply. I really appreciate that. I will update once I start working on this...
Thank you again,
Rajeev
I have modified the foreach section as following to achieve this.
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
//current month value to compare
string monthYear=String.Empty;
var nodes =Model.Descendants().Where("Visible")
.OrderBy("displayDate")
.Where("displayDate >= DateTime.Now.Date && displayDate < DateTime.Now.Date.AddMonths(5)");
@foreach (var item in nodes)
{
//if the month changed to another month then display monthyear header
@if(!monthYear.Equals(item.displayDate.ToString("MMMM yyyy")))
{
monthYear=item.displayDate.ToString("MMMM yyyy");
@monthYear
}
@item.title
@item.description
}
}
Thank you Dan again for your help.
Rajeev
hi
how can i achieve above in jsonstring
nov 2012
event related data
dec 2012
event related data
hi
above where condition is not wotking in 4.7.1.1 how to rectify it.
is working on a reply...