This is a great question! And a good candidate for a custom widget using the AutoWidgetContentFinder velocity method. YOu can see two examples of this in use in these blog posts:
https://www.percussion.com/blog/2015/October/widget-builder-building-a-related-content-widget-builde…
https://www.percussion.com/blog/2015/November/widget-builder-building-a-contextually-based-pagelist
For your purposes, Andrew, you could create a custom widget that would allow you to enter the folder path as a variable name into the $query variable that holds the JCR query to the database.
There are additional parameters that can be added to that JCR query such as:
ordering:
"order by rx:sys_contentpostdate desc"
or filtering by date:
rx:sys_contentpostdate > ‘2015-01-01 00:00:00’
rx:sys_contentpostdate > '2015-12-31 23:59:59’
You can use the date field type in the widget builder to make date selection easy.
The JCR query options can be set using variables for folderpath and year from your custom widget fields and then combined into the following for example:
"select rx:sys_contentid, rx:sys_folderid from rx:percPage where (jcr:path like ‘/$folderLocation/%’ OR jcr:path like ‘/$folderLocation2/%’) AND rx:sys_contentpostdate > ‘$yearStart’ AND rx:sys_contentpostdate < ‘$yearEnd’ order by rx:sys_contentpostdate desc"
Once you have you query properly formed we can set the rest of our AWCF params:
#set($params=$rx.string.stringToMap(null)) ##
#set($dummy=$params.put(‘max_results’, $maxResults )) ##
#set($dummy=$params.put(‘query’, $query)) ##
#set($finderName=“Java/global/percussion/widgetcontentfinder/perc_AutoWidgetContentFinder”) ##
Notice we can add an additional maxResults variable as a field in our custom widget as well.
Then we pass the parameters into the AutoWidgetContentFinder method:
#set($relresults= $rx.pageutils.widgetContents($sys.assemblyItem, $perc.widget, $finderName, $params))##
The method returns a list of objects into the variable $relresults that we can then iterate on using a velocity forloop. To start with let’s output the raw data to see what we’re working with:
#foreach($result in $relresults)##
**
Result
$result
#end##**
You’ll see the assembly object with a list of key-value pairs of properties. The calendar event properties you’re looking for here are names:
page_start_date
page_end_date
page_calendar
You can use the velocity set statement to get values from the objects and them generate your HTML with them. For example:
#set($eventStart = $result.node.getProperty(‘rx:page_start_date’).getString())##
#set($eventEnd = $result.node.getProperty(‘rx:page_end_date’).getString())##
#set($calendars= $result.node.getProperty(‘rx:page_calendar’).getValues())##
Andrew, I hope that information helps along in your development on this widget. I wrote a bit more than I anticipated so you can expect i’ll be writing this up as a blog post soon to share with other community users as well.
Additionally, here’s a link to Apache’s velocity user guide for reference on working with loops and variables and such:
http://velocity.apache.org/engine/releases/velocity-1.4/user-guide.html
Best,
Piotr