10387 Posts in 2198 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 843 Views |
-
Linking to CMS folder?

15 April 2009 at 2:51pm
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.
-
Re: Linking to CMS folder?

16 April 2009 at 1:24am
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"); -
Re: Linking to CMS folder?

27 April 2009 at 8:49am
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.
-
Re: Linking to CMS folder?

27 April 2009 at 8:47pm
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 ...
| 843 Views | ||
|
Page:
1
|
Go to Top |


