Skip to content

Reuters tutorial: step 9

jpmckinney edited this page Sep 13, 2010 · 20 revisions

Table of Contents

Adding a calendar widget will introduce the Solr date faceting parameters.

First, update the Solr parameters for faceting in reuters.js:

var params = {
  ...
  'facet.date': 'date',
  'facet.date.start': '1987-01-01T00:00:00.000Z/DAY',
  'facet.date.end': '1987-11-31T00:00:00.000Z/DAY+1DAY',
  'facet.date.gap': '+1DAY',
  ...
};

Create a new widget, CalendarWidget.js, inheriting from AbstractFacetWidget:

(function ($) {
AjaxSolr.CalendarWidget = AjaxSolr.AbstractFacetWidget.extend({
});
})(jQuery);

Add the JavaScript file:

<script type="text/javascript" src="widgets/CalendarWidget.js"></script>

And add an instance of the widget to the Manager in reuters.js:

Manager.addWidget(new AjaxSolr.CalendarWidget({
  id: 'calendar',
  target: '#calendar',
  field: 'date'
}));
Clone this wiki locally