Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Linking to CMS folder?

Go to End

4 Posts   1257 Views


Community Member, 4 Posts

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.


Community Member, 791 Posts

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");


Community Member, 4 Posts

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.


Community Member, 791 Posts

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 :


<% control GetFiles %>
<% end_control %>

Make sure to go through the tutorials on this site to get a basic grasp of Silverstripe's architecture ...