Is there an easy way to link a folder in the cms (or in the root dir /) to a page so that the files in the folder are listed on the page and are accessible publicly? The only way I am able to do this is by linking each individual file into a page. This is tedious. In my situation, silverstripe is in the root directory, so anonymous users cannot see inside of specified webfolders.
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.
AFAIK Not by using default page-types , no.
You can do something like :
// Get the directory ID
$leftDir = DataObject::get_one("Folder", "Name = \"DIRECTORYNAME\"");
// Get files from directory
$allFilesFromDirectory = DataObject::get("File","ParentID = $left_dir->ID");
Im sorry for the noob question, but is that code for a module class? SS page? Page type? I get the gist of what the code is doing, but I dont know where that code should be placed.
You put that code into your controller class (for example in the file Page.php in the class Page_Controller.php)...
If you finish the code and place it in it's own method e.g. GetFiles() , you can then call that methode from your template :
e.g.
<% control GetFiles %>
$Title
<% end_control %>
Make sure to go through the tutorials on this site to get a basic grasp of Silverstripe's architecture ...