Skip to content

Commit b22f4f9

Browse files
committed
Adds an example to the README
1 parent 6633bed commit b22f4f9

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

+45
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,48 @@ In your template, use the filter like this:
1919
```
2020

2121
If `tf_slug` is not provided, it defaults to the value of `{{ last_segment }}`.
22+
23+
## Example
24+
25+
Say you have a collection with the slug `events` and you want to filter them based on a related Taxonomy that has the slug `events-categories`.
26+
27+
In each `event` entry, you would have an array with the same name as the Taxonomy's slug, `events-categories` like this:
28+
29+
```
30+
events-categories:
31+
- 820aea27-1925-44a0-8819-ac12f4a9e0a7
32+
- 6594680e-3a94-4e54-a4ad-aa031995af66
33+
- 0246bd34-ef66-4c4c-8191-98461b58a215
34+
```
35+
36+
… where each of those IDs matches-up with IDs in the `events-categories` Taxonomy.
37+
38+
In my use case, I'm trying to filter based on the URI `/events/categories/summer`, grabbing only (upcoming) events tagged as "summer".
39+
40+
### Template
41+
42+
```
43+
{{ collection:events filter="TaxonomyFilter"
44+
tf_group="events-categories"
45+
tf_slug="{ slug }"
46+
sort="date:asc"
47+
show_future="yes"
48+
show_past="no"
49+
as="events"
50+
}}
51+
{{ unless no_results }}
52+
<h2>
53+
<small>Upcoming events tagged:</small><br>
54+
{{ slug|deslugify }}
55+
</h2>
56+
{{ events }}
57+
{{ partial:calendar/item }}
58+
{{ /events }}
59+
{{ else }}
60+
<p>
61+
It seems there are no upcoming events
62+
in the category "<strong>{{ slug|deslugify }}</strong>"
63+
</p>
64+
{{ /unless }}
65+
{{ /collection:events }}
66+
```

0 commit comments

Comments
 (0)