Using a File from File-Module
Created 5 years ago by afx

Hi! I am super new to Pyro and I have a basic questions.

I have uploaded a file in the backend using the built-in files module: Filename: alpspitze.jpg

How can I use this file in the frontend? More specifically in the a php-file of my Theme. So I need the complete absolute path (e.g. app/default/files...../alpspitz.jpg)

How do I accomplish that?

Thanks in Advance. AFX

cs42na  —  5 years ago

{% set folder = entries('files','folders').findBySlug('folder_slug') %} {% set files = entries('files').where('folder_id','=', folder.id).get() %} {% for file in files %} {{ file.downloadPath() }} {% endfor %}

the downloadPath will give you the url for download.

finnito  —  5 years ago

Hey @afx! There are two good ways to do it:

1st Way: Variables Modules Install the Variables Module and then create a variable with field type image (or file) and then assign it to a Variable Group called Theme (or whatever you like). Then in your frontend you can do something like:

{{ variable(“theme”,”variable_slug”) }}

2nd Way: Settings I like this way. Open up the docs on creatinf settings for an addon (like a theme) https://pyrocms.com/documentation/settings-module/2.1/introduction/settings and go ahead and create the file setting.

Then go and check the “Plugin” section of those docs for how to display your setting