College of Education and Human Development wordmark.

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.

events_feed_js macro parameters
OrderParameterDescriptionDefault
firstt parameter valuethe tag idNone (value required)
secondlimitThe number of results to retrieve from the calendar3
thirdtarget element selectorThe JQuery selector for the element where events should be rendered#events-container
fourthpath to templateThe path to the directory where the Nunjucks template is/assets/dist/views/cehd/events
fifthNunjucks template nameThe name of the Nunjucks template used to render the eventsindex.html
sixthq parameter valuethe 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 date6 (no end date)
seventhr parameter valuethe 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.