Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

List of files-names with thumbnails (theme : quark)

Solved by byache View solution

Started by byache 5 years ago · 6 replies · 626 views
5 years ago

Hello,
I have a few files (odt and pdf, and images) in the page-folder of a 'subsection.md' file (theme quark).
My file 'subsection.html.twig' is :

{% embed 'sections.html.twig' %}
{% endembed %}

So I put this code in the file 'sections.html.twig' :

TWIG
<ul>
{% for file in page.media.data %}
<li>
    <div class="file-surround">
        {{ file.link().html|raw }}{{ file.meta.title }}
    </div>
</li>
{% endfor %}
</ul>

But it doesn't work... Can someone give me a little help ?
Thank you !

5 years ago

I'm not at my Grav PC now, so not sure if html() produces the icon, but I believe you should call instead of file.link().html|raw call simply file.html()|raw. Also I myself use page.media.files - don't know what page.media.data returns actually. Also, you should define icons in media.yaml for missing file types (I believe odt is one of them)

5 years ago

Thank you, with "page.media.files" it render something : a list of the files' names.
But no link and no thumbnails...
And I don't succeed in using the link() function.
What I want to get is a list of links with for each of them, a thumbnail corresponding to the type of the file...

5 years ago

Not sure what you're missing. If you have defined file extension in media.yaml, it should work. I just tried on my page:

TWIG
 {{ file.link().html()|raw }}

And I've got linked thumbnail rendered on page 🤔

5 years ago

You're right, after deleted the .odt files and clear the cache, it works.
So is there a bug with odt files ?
In user/config/media.yaml, I write :

YAML
  odt:
    type: file
    thumb: media/thumb-odt.png
    mime: application/vnd.oasis.opendocument.text
5 years ago

I'm a bit lost 🙂 If you say it works, what bug are you talking about? :)

5 years ago Solution

It seems to be all right (even with odt files).
I don't understand, but the solution was to clear the cache "compiled/config".
Thank you for your help.

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 96 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 147 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago