Skip to content

Commit fa24651

Browse files
committed
update readme and plugin requirements
1 parent d6045bf commit fa24651

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
**This README.md file should be modified to describe the features, installation, configuration, and general usage of the plugin.**
44

5-
The **Popular Articles** Plugin is an extension for [Grav CMS](http://github.com/getgrav/grav). Display a list of the most popular articles from a blog
5+
The **Popular Articles** Plugin is an extension for [Grav CMS](http://github.com/getgrav/grav). Display a list of links to the most popular articles from a blog.
6+
7+
> NOTE: This plugin requires the admin plugin to be installed.
68
79
## Installation
810

@@ -37,20 +39,46 @@ Before configuring this plugin, you should copy the `user/plugins/popular-articl
3739
Here is the default configuration and an explanation of available options:
3840

3941
```yaml
40-
enabled: true
42+
enabled: true
43+
blog_route: /blog # route under where the articles can be found
44+
articles_count: 5 # number of articles displayed
4145
```
4246
4347
Note that if you use the Admin Plugin, a file with your configuration named popular-articles.yaml will be saved in the `user/config/plugins/`-folder once the configuration is saved in the Admin.
4448

4549
## Usage
4650

47-
**Describe how to use the plugin.**
51+
Just add the lines in the templates you want to display the list:
52+
53+
```twig
54+
{% if config.plugins['popular-articles'].enabled %}
55+
{% include 'partials/popular_articles.html.twig' %}
56+
{% endif %}
57+
```
58+
59+
Don't forget to enable the plugin in the plugin configuration (see above).
4860

49-
## Credits
61+
It's recommended to override the original template to suit your needs (then save it to templates/partials/popular_articles.html.twig in your theme):
5062

51-
**Did you incorporate third-party code? Want to thank somebody?**
63+
```twig
64+
{% set articles_list = popular_articles.get() %}
65+
66+
<h4>
67+
{{ 'PLUGIN_POPULAR_ARTICLES.POPULAR_ARTICLES'|t }}
68+
</h4>
69+
70+
<ul>
71+
{% for article in articles_list %}
72+
<li>
73+
<a href="{{ base_url }}{{ article.route }}">
74+
{{ article.title }}
75+
</a>
76+
</li>
77+
{% endfor %}
78+
</ul>
79+
```
5280

5381
## To Do
5482

55-
- [ ] Future plans, if any
83+
- add title translations (only english and french right now)
5684

blueprints.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Popular Articles
22
slug: popular-articles
33
type: plugin
4-
version: 0.1.0
4+
version: 1.0.0
55
description: Display a list of the most popular articles from a blog
66
icon: plug
77
author:
@@ -15,6 +15,7 @@ license: MIT
1515

1616
dependencies:
1717
- { name: grav, version: '>=1.6.0' }
18+
- { name: admin, version: '>=1.0.0' }
1819

1920
form:
2021
validation: loose

0 commit comments

Comments
 (0)