Skip to content

Instantly share code, notes, and snippets.

@ruemic
Created September 19, 2013 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruemic/6629731 to your computer and use it in GitHub Desktop.
Save ruemic/6629731 to your computer and use it in GitHub Desktop.
An calendar extension for Webpop for sorting entries that occur in the future into months.
// Use <pop:calendar:months> within the scope of entries to generate
// a timeline array of all the months which have entries
exports.months = function(options) {
if (!section) return null;
var result = site.search({
all: true,
filters: {section: section, date: "future" },
timeline: {date: "month"},
}).timeline;
return result;
// Returns a simple array of months with 'start' & 'end' atrributes
};
// Use <pop:entries_for start="<pop:start/>" end="<pop:end/>"> inside of <pop:calendar:months>
// to render a collection of entries with a date between the specified 'start' and 'end' date.
exports.entries_for = function(options) {
if (!section) return null;
var start = new Date(options.start), end = new Date(options.end);
if ( new Date() > start )
start = new Date()
var results = site.search({
all: true,
filters: {section: section, date: {from: start, to: end}},
order: "date ASC"
}).results;
return results;
// Returns an array of entries which you can render out
// in your templates like a regular <pop:entries> tag.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment