Jump to:

23481 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Showing all files of a folder as links. Noob need help :)

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 1062 Views
  • LaDDat
    Avatar
    Community Member
    5 Posts

    Showing all files of a folder as links. Noob need help :) Link to this post

    Hello everybody,
    i created a Homepage with SS but i need some help:
    How can a page create links to files of a folder automatically? So i dont have to create all links by hand. Is this possible?
    I am quit noobish with php and html. So if it must done with this, i need a detailed description. Is there a module for such things?
    Thx for help.

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Showing all files of a folder as links. Noob need help :) Link to this post

    Hi LaDDat,

    Welcome to the Forums!

    I'm going to give you the dreaded "please try the tutorials first" message here... there is far too much to explain without a base of understanding from you... after you have done the tutorials even if you don't then know how to do this, you'll have an idea and then I'd help you out. I think after you've done the tutorials, you'll know how to do this...

  • LaDDat
    Avatar
    Community Member
    5 Posts

    Re: Showing all files of a folder as links. Noob need help :) Link to this post

    Thx 4 the answer,
    but where can i find good tutorials? I was looking for it, but didnt find anything. Was i blind?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts
  • LaDDat
    Avatar
    Community Member
    5 Posts

    Re: Showing all files of a folder as links. Noob need help :) Link to this post

    Hello again,
    i worked through the tutorials. But i need still help. I have little overview now about the structure of SS.
    For my project i created a new pagetype ("datapage.php"). I am guessing that i must use the content controller to show all files in an uploaded folder. But i need help to create such a "datapage.php"-File. Can neone send me an example?
    Greetings

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Showing all files of a folder as links. Noob need help :) Link to this post

    Is http://doc.silverstripe.org/framework/en/tutorials/2-extending-a-basic-site not showing you how to a) make a new page, b) create a template that iterates over databobject/datalists?

    That is the basic - the only small part then is reading from a folder.

    You will never need to modify any silverstirpe cms/framework files... only add a new page and template... if the second template didn't explain how to add a new page / template - I'm going to struggle doing a better job of explaining... maybe you could post the "code in progress"?

  • lerni
    Avatar
    Community Member
    80 Posts
  • LaDDat
    Avatar
    Community Member
    5 Posts

    Re: Showing all files of a folder as links. Noob need help :) Link to this post

    Hi again,
    thx for the help so far, but...
    i really have problems understanding the tutorial since english is not my native.
    could u pls post an existing example or mb just a step by step discription.

    here is my php file wich i created so far:
    <?php
    class dataPage extends Page {

       public static $db = array(
        'SubTitle' => 'Varchar(255)',
       );
       function getCMSFields() {
       $fields = parent::getCMSFields();

       $fields->addFieldToTab('Root.Content.Main', new TextField('SubTitle'), 'Content');
       return $fields;
       }
       function getData() {
       $folder = DataObject::get_one("Folder", "Filename = 'assets/upload/10.Klasse/Alkohle'");
       $folder = DataObject::get_one("Folder", "Filename = 'assets/upload/10.Klasse/Alkohle'");
       return $folder;
       }
    }
    class dataPage_Controller extends ContentController {

       /**
        * An array of actions that can be accessed via a request. Each array element should be an action name, and the
        * permissions or conditions required to allow the user to access it.
        *
        * <code>
        * array (
        * 'action', // anyone can access this action
        * 'action' => true, // same as above
        * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
        * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
        * );
        * </code>
        *
        * @var array
        */
       public static $allowed_actions = array (
       );

       public function init() {
          parent::init();

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work
          Requirements::themedCSS('reset');
          Requirements::themedCSS('layout');
          Requirements::themedCSS('typography');
          Requirements::themedCSS('form');
       }

    }

    Well i am sorry that i dont understand it better.

    1062 Views
Page: 1 2
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.