List files in Dir using Pyro
Frage
I want to list all files in a directory Using PyroCMS.
Using the Files module each client has their own folder, the folder is their User ID
\files\clients\{ID}\
I need something like this.
{{ foreach file in { files:/clients/{{ user:id }} } }}
<a href="{{files:current_file_name_and_ext}}">{{files:current_file_name}}</a>
{{ endif }}
Lösung
You should be able to do something like this...
{{ files:listing folder="/files/clients/{{ client_id }}" }}
<a href="{{ url:site }}files/clients/{{ filename }}">Download {{ name }}</a>
{{ /files:listing }}
You will need to set the client_id variable though. You could set it in your contoller and use:
$this->template
->set('client_id', $client_id)
->build('page-template-goes-here');
Or even use the current user with the tag:
{{ user:id }}
I haven't tested this, but you should be able to get something going.
From here:
http://docs.pyrocms.com/2.1/manual/index.php/modules-and-tags/tag-reference/files http://docs.pyrocms.com/2.1/manual/index.php/modules-and-tags/tag-reference/user
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow