Skip to content
● Critical PHP security fixes are out: update PHP on your Grav sites. What to do →

Use Aura Authors to generate a list of all authors

Started by paul 6 years ago · 0 replies · 867 views
6 years ago

I recently came across the Aura Authors plugin and wanted to find a way to list all the authors stored in the plugin's config on an "About Us" page.

Just wanted to share how I did it for users like me who aren't skilled with twig. It turned out to be much simpler than I expected:

  1. Copy author-bio.html.twig and placed at templates/partials/all-author-bios.html.twig

  2. Replace line 1: {% set author = authors[page.header.aura.author] %} with {% for author in config.plugins['aura-authors'].authors %}. Now, rather than looking for the author on a given page, the twig loops through all of the authors in the config and renders their bio box.

  3. Add {% endfor %} at the end to close the loop.

  4. Optionally remove lines 12-13:

    TWIG
        <p class="author-heading">About the author</p>
        <hr />
    
  5. Add to the relevant template or (if you have twig processing in pages enabled) in the page markdown:

    TWIG
    {% include 'partials/all-author-bios.html.twig' ignore missing %}
    

You can manually adjust the order the authors appear in Admin > Plugins > Aura Authors, or you can use twig to sort alphabetically. The plugin currently has one single name field without a separate field for surnames. To sort by names, replace the top line edited in step 2 above with the following:

TWIG
{% set sorted_authors = config.plugins['aura-authors'].authors|sort_by_key('name') %}
{% for author in sorted_authors %}

Suggested topics

Topic Participants Replies Views Activity
Plugins · by DrPen, 2 days ago
1 66 4 hours ago
Plugins · by renedebaaij, 1 week ago
1 134 3 days ago
Plugins · by Thomas, 6 days ago
1 143 5 days ago
Plugins · by complanar, 4 weeks ago
6 470 3 weeks ago
Plugins · by BenLaKnet, 3 weeks ago
1 294 3 weeks ago