Hello,
I want to know how can i display all the files from assets/Custom Folder to Front-end ? with possibility for user to download them. Every user must log in before they can see those files listed, and every user will/can see different files(already done the module with linking files to users, the table looks like this in database ID | FileID | UserID )
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi Johny
here are some basic ideas only:
Pseudo code goes like this:
MyPage_Controller {
function Files(){
$arrayList = ArrayList::create();
$files = File::get()->filter("ParentID", $folder-ID);
foreach($files as $file) {
if($file->canView()) {
$arrayList->push($file);
}
}
}
}
in template:
<% loop Files %>
<li><a href="$DownloadLink">$Title</a></li>
<% end_loop %>
Now all you need to do is to create a DownloadLink function on File. I'd actually google this or look in addons.silverstripe.org for any modules that include "forced" downloads (rather than views).
e.g see http://www.silverstripe.org/community/forums/general-questions/show/15832