Solution: How to fetch content based on view parameter date range

Summary

This solution is template based and very simple.

It optionally relies on view parameters to provide a date range with which to limit the fetch results.

{* Example: http://example/layout/set/content_statistics.csv/(startDate)/2010-07-14/(endDate)/2010-07-19/ *}
{def $articles=false()}
 
{if and( is_set( $view_parameters.startDate ), is_set( $view_parameters.endDate ) )}
 
{def $startDate=$view_parameters.startDate|explode("-")
$endDate=$view_parameters.endDate|explode("-")}
 
{def $startDateTimestamp=maketime(0,0,0,$startDate.1,$startDate.2,$startDate.0)
$endDateTimestamp=maketime(23,59,59,$endDate.1,$endDate.2,$endDate.0)}
 
{set $articles=fetch( 'content', 'list', hash(
     'parent_node_id', 77,
     'class_filter_type', 'include',
     'class_filter_array', array( 'article' ),
     'sort_by', array( 'published', false() ),
     'attribute_filter', array( array( 'published', '>=', $startDateTimestamp ),
                                array( 'published', '<', $endDateTimestamp ) )
 ) )}
{else}
 
{set $articles=fetch( 'content', 'list', hash(
     'parent_node_id', 77,
     'class_filter_type', 'include',
     'class_filter_array', array( 'article' ),
     'sort_by', array( 'published', false() ),
     'limit', 10000
 ) )}
{/if}

References

These forum threads were the basis for this solution. Thanks to the contributors for the hints and tips.