Jump to:

10987 Posts in 2724 Topics by 1817 members

All other Modules

SilverStripe Forums » All other Modules » Linking to CMS folder?

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 972 Views
  • cantormath
    Avatar
    Community Member
    4 Posts

    Linking to CMS folder? Link to this post

    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.

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Linking to CMS folder? Link to this post

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

  • cantormath
    Avatar
    Community Member
    4 Posts

    Re: Linking to CMS folder? Link to this post

    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.

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Linking to CMS folder? Link to this post

    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 ...

    972 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.