UNPKG

3.59 kBMarkdownView Raw
1[![CircleCI](https://circleci.com/gh/apostrophecms/apostrophe-events/tree/master.svg?style=svg)](https://circleci.com/gh/apostrophecms/apostrophe-events/tree/master)
2
3# apostrophe-events
4
5This bundle provides a complete foundation for displaying upcoming events with the [Apostrophe CMS](http://apostrophenow.org).
6
7The bundle consists of three Apostrophe modules (in a single npm module):
8
9* `apostrophe-events`
10* `apostrophe-events-pages`
11* `apostrophe-events-widgets`
12
13The `apostrophe-events` module provides the ability to create and edit events and manage their start and end dates and times. There is support for repeating events.
14
15The `apostrophe-events-pages` module displays events on a page. It extends the `apostrophe-pieces-pages` module. The default view displays only upcoming events.
16
17The `apostrophe-events-widgets` module provides an `apostrophe-events` widget, which you can use to select events to appear anywhere on your site. Events that have ended do not appear in widgets.
18
19These three modules extend `apostrophe-pieces`, `apostrophe-pieces-pages` and `apostrophe-pieces-widgets`, and you can extend them further as well.
20
21## Example configuration
22
23For a single collection of events:
24
25```javascript
26// in app.js
27// We must declare the bundle!
28bundles: [ 'apostrophe-events' ],
29modules: {
30 'apostrophe-events': {},
31 'apostrophe-events-pages': {},
32 'apostrophe-events-widgets': {},
33 'apostrophe-pages': {
34 // We must list `apostrophe-events-page` as one of the available page types
35 types: [
36 {
37 name: 'apostrophe-events-page',
38 label: 'events'
39 },
40 {
41 name: 'default',
42 label: 'Default'
43 },
44 {
45 name: 'home',
46 label: 'Home'
47 }
48 ]
49 }
50}
51```
52
53## Multiple collections of events
54
55One way to create two or more distinct collections of events is to create separate events pages on the site, and use the "with these tags" feature to display only events with certain tags.
56
57Another approach is to `extend` the modules, creating new modules and a completely separate admin bar item for managing the content. If you take this approach, you must set a distinct `name` property when configuring your subclass of `apostrophe-events`, such as `meeting`. This will be value of `type` in the database for each event of this subclass.
58
59The latter approach is often best as it requires less user training to avoid confusion. The former approach has its own advantages, notably that it is easier to aggregate content and have it appear in multiple places intentionally.
60
61## Filtering by year, month and day
62
63The `apostrophe-events` module provides cursor filters named `year`, `month`, and `day`. For `year` the value should be a 4-digit year. For `month` the value should be in `YYYY-MM` format. For `day` the value should be in `YYYY-MM-DD` format.
64
65All events which are in progress at any point during the specified year, month or day will be included in the results.
66
67These filters are marked `safeFor: public` and can be used with the `piecesFilters` option in `apostrophe-events-pages`.
68
69For example:
70
71```javascript
72// in lib/modules/apostrophe-events-pages/index.js
73 piecesFilters: [
74 {
75 name: 'year'
76 }
77 ]
78```
79
80```markup
81<!-- In lib/modules/apostrophe-events-pages/views/index.html -->
82<li><a class="{{ 'active' if not data.query.year }}" href="{{ here({ year: null }) }}">Upcoming</a></li>
83{% for year in data.piecesFilters.year %}
84 <li><a class="{{ 'active' if data.query.year == year.value }}" href="{{ here({ year: year.value }) }}">{{ year.label }}</a></li>
85{% endfor %}
86```
87