Events macro
Note: This is no longer the preferred way to handle news feeds. See see the updated method here.
Include the eventsfeed macro
{%- import "macros/events-feed.html" as eventsfeed -%}
Call the macro inside a bottom_js block
{% block bottom_js %}{{ parent() }}
{# The call to parent() above is *very* important #}
{{ eventsfeed.events_feed_js(355) }}
{% endblock %}
The events calendar "Link Pro" sets up query parameters to pull in different feeds. For example, an XML feed will look something like this: http://apps.cehd.umn.edu/events/Admin/XMLFeed.aspx?&r=1&q=6&t=355
t=355 above is the id for the tag we want to
use. In many cases you won't need any more information than
that. Thus, the tag id is the first parameter for pulling in
events. So we call the macro like:
{{
events.events_feed_js(355) }}.
The table below lists all the parameters for the events_feed_js macro.
Order | Parameter | Description | Default |
---|---|---|---|
first | t parameter value | the tag id | None (value required) |
second | limit | The number of results to retrieve from the calendar | 3 |
third | target element selector | The JQuery selector for the element where events should be rendered | #events-container |
fourth | path to template | The path to the directory where the Nunjucks template is | /assets/dist/views/cehd/events |
fifth | Nunjucks† template name | The name of the Nunjucks template used to render the events | index.html |
sixth | q parameter value | the value to use for the q query parameter in the request to the events calendar. E.g., http://apps.cehd.umn.edu/events/Admin/XMLFeed.aspx?&r=1&q=6&t=355, End date: 6 = no end date | 6 (no end date) |
seventh | r parameter value | the value to use for the r query parameter in the request to the events calendar. E.g., http://apps.cehd.umn.edu/events/Admin/XMLFeed.aspx?&r=3&q=6&t=355, Start date: 1 = no start date | 3 = start from today. | 3 (start from today) |
Just set up the feed you want to pull in and review the r, q and t query parameters to see if you need to override the defaults.
Calling macro with all parameters
{% block bottom_js %}{{ parent() }}
{# The call to parent() above is *very* important #}
{{ events.events_feed_js(
255,
2,
"#events-container",
"/assets/dist/views/cehd/events",
"special-template.html",
6,
3
) }}
{% endblock %}
† Nunjucks is a JavaScript template engine that has a syntax almost identical to Twig.