Custom File Icons

Liquid snippet to output Font Awesome Icons for downloadable files from a Custom Module.

v1.0.0
  1. Add this code somewhere at the top of your Module layout.

    This code assumes you have a custom field called 'Icon' which accepts predefined file type values as below. Add your own or change as required.

    <!--Treehouse CODE v1.0.0-->
    {% if this['Icon'] == 'PDF' %}
        {% capture faIcon %}<i class="fal fa-file-pdf"></i>{% endcapture %}
    {% elsif this['Icon'] == 'EXCEL' %}
        {% capture faIcon %}<i class="fal fa-file-excel"></i>{% endcapture %}
    {% elsif this['Icon'] == 'DOC' %}
        {% capture faIcon %}<i class="fal fa-file-word"></i>{% endcapture %}
    {% elsif this['Icon'] == 'POWERPOINT' %}
        {% capture faIcon %}<i class="fal fa-file-powerpoint"></i>{% endcapture %}
    {% elsif this['Icon'] == 'NUMBERS' %}
        {% capture faIcon %}<i class="fal fa-file-spreadsheet"></i>{% endcapture %}
    {% endif %}
  2. Then simply use {{faIcon}} next to your file name/link:

    <!--Treehouse CODE v1.0.0-->
    {{faIcon}} <a href="#">YOUR FILE NAME</a>

Comments or questions? Head over to the Treepl CMS forum to discuss with the community.