Grav: GRAV display all page media items (pdf files)

Created on 5 Oct 2018  路  2Comments  路  Source: getgrav/grav

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 :)

question

Most helpful comment

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

All 2 comments

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...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

giansi picture giansi  路  17Comments

gizmecano picture gizmecano  路  17Comments

fabrizioT picture fabrizioT  路  26Comments

Japhys picture Japhys  路  21Comments

ekumlin picture ekumlin  路  37Comments