if ( NOT StructKeyExists(request.params, "year") )
request.params.year = Year(now());
if ( NOT StructKeyExists(request.params, "month") )
request.params.month = MONTH(now());
monthFilterText = "Filter by Month:";
goButtonText = "Go";
allOptionText = "All";
currentYearStart = "";
currentMonthStart = "";
// Get all the potential month and year values
newsPubDatesList = application.ptNews.ceData.getCEFieldValues("News Article", "publicationDate");
if ( ListLen(newsPubDatesList) ){
monthStart = MONTH(ListFirst(newsPubDatesList));
yearStart = YEAR(ListFirst(newsPubDatesList));
monthEnd = MONTH(ListLast(newsPubDatesList));
yearEnd = YEAR(ListLast(newsPubDatesList));
}
else {
monthStart = MONTH(now());
yearStart = YEAR(now());
monthEnd = MONTH(now());
yearEnd = YEAR(now());
}
// if the user selected "all" for the year then use the first known year.
if ( request.params.year EQ "all" ){
currentYearStart = yearStart;
currentYearEnd = yearEnd;
}
else {
currentYearStart = request.params.year;
currentYearEnd = request.params.year;
}
// if the user selected "all" for the months then use January.
if ( request.params.month EQ "all" ) {
currentMonthStart = 1;
currentMonthEnd = 12;
}
else {
currentMonthStart = request.params.month;
currentMonthEnd = request.params.month;
}
// Build the filters for the element render mode
request.params.newsFilterStartDate = application.ptNews.date.firstOfMonth(inMonth="#currentMonthStart#", inYear="#currentYearStart#");
request.params.newsFilterEndDate = application.ptNews.date.lastOfMonth(inMonth="#currentMonthEnd#", inYear="#currentYearEnd#");