|
2 | 2 |
|
3 | 3 | **This README.md file should be modified to describe the features, installation, configuration, and general usage of the plugin.** |
4 | 4 |
|
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. |
6 | 8 |
|
7 | 9 | ## Installation |
8 | 10 |
|
@@ -37,20 +39,46 @@ Before configuring this plugin, you should copy the `user/plugins/popular-articl |
37 | 39 | Here is the default configuration and an explanation of available options: |
38 | 40 |
|
39 | 41 | ```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 |
41 | 45 | ``` |
42 | 46 |
|
43 | 47 | 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. |
44 | 48 |
|
45 | 49 | ## Usage |
46 | 50 |
|
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). |
48 | 60 |
|
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): |
50 | 62 |
|
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 | +``` |
52 | 80 |
|
53 | 81 | ## To Do |
54 | 82 |
|
55 | | -- [ ] Future plans, if any |
| 83 | +- add title translations (only english and french right now) |
56 | 84 |
|
0 commit comments