Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobdenotter/yearly-monthly-archives
This extension allows your site to have 'monthly archives' or 'yearly archives', which are used often on blog-like websites.
https://github.com/bobdenotter/yearly-monthly-archives
Last synced: 25 days ago
JSON representation
This extension allows your site to have 'monthly archives' or 'yearly archives', which are used often on blog-like websites.
- Host: GitHub
- URL: https://github.com/bobdenotter/yearly-monthly-archives
- Owner: bobdenotter
- Created: 2015-06-09T15:03:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-15T19:08:30.000Z (over 6 years ago)
- Last Synced: 2024-05-01T20:38:34.018Z (6 months ago)
- Language: PHP
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Monthly and Yearly Archives
===========================This extension allows your site to have 'monthly archives' or 'yearly
archives', which are used often on blog-like websites, or to organize a larger
archive of newsitems. This extension takes care of creating the 'list of links', as well as populating the actual archive pages.![screen](https://cloud.githubusercontent.com/assets/1833361/8061500/65de807a-0ecb-11e5-9851-afb4b6772419.png)
To use, place the following tag in your template, where you'd like the list of links:
```twig
Monthly entry archives
{{ monthly_archives('entries') }}
```
or
```twig
Yearly news archives
{{ yearly_archives('news', 'asc') }}
```
The parameter passed, is the contenttype that's used for the archives. Be sure to pass this as a strings, _with_ the quotes. The second parameter can de `'asc'` or `'desc'`, and determines whether the results will be shown ascending (oldest first) or descending (newest first).
You can also pass the name of the column to sort on and/or the label to use. By this point, it becomes better to use named arguments for clarity.
```twig
Monthly calendar
{{ monthly_archives(content_type_name = 'entries', order = 'asc', column = 'start_date') }}
Monthly news archives
{{ monthly_archives(content_type_name = 'entries', label = 'In the month %B of %Y.') }}
```
Note: In most cases you do _not_ want to set `column` in the twig tag, but rather in `app/config/extensions/archives.bobdenotter.yml`, because that way it'll automatically work on the listing pages as well.
You can also specify a twig template that is used to render the list. For instance, that is useful if you want to add a class to the list items.
```twig
Monthly entry archives
{{ monthly_archives(content_type_name = 'entries', template = 'my-archive-list.twig') }}
```
In your template directory, create a file `my-archive-list.twig` that looks similar to this:
```twig
{% for item in list %}
{% endfor %}
```