Created
September 19, 2013 20:58
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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