I have created a page in wich i want to display all pdf files that i have uploaded in grav in this page.
How wold i achieve this?
I tried this:
<ul class="downloads">
<li class="download-item pb-3">
<i class="fas fa-file-pdf fa-lg"></i>
<a href="{{ page.find('/pdf') }}" class="action-btn m-0" download></a>
</li>
</ul>
And this:
<ul class="downloads">
{% for pdf in page.media %}
<li class="download-item pb-3">
<i class="fas fa-file-pdf fa-lg"></i>
<a href="{{ pdf.url }}" class="action-btn m-0" download></a>
</li>
{% endfor %}
</ul>
none of this worked... help please :)
hi,
I will do something like this (not tested)
````
```
You can loop through only矛mageswithpage.media.imagesI test themimetype because withpages.media.files`you can have another type of files (svg, pdf etc)
Hope it helps
Is this even mentioned in the docus?seems important info...
Most helpful comment
hi,
I will do something like this (not tested)
````
{% for file in page.media.files %} {% set mediatype = file.mime %} {% set url = file.url %} {% set filename = file.filename %} {% set type = file.type %} {% if ('pdf' in mediatype) %}-
I'am a {{ mediatype }} file and my name is {{filename }} my type is {{ type }}
{% endif %}
{% endfor %}
```
You can loop through only矛mageswithpage.media.imagesI test themimetype because withpages.media.files`you can have another type of files (svg, pdf etc)Hope it helps