Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Setting folder 'title'

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 942 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    Setting folder 'title' Link to this post

    I'm currently uploading files with a filefield and using the following code (more or less):

    public function addFile($data, $form)
          {
             $file = new ProjectFile();
             $folder = $this->ProjectPage()->URLSegment;
             $file->loadUploaded($_FILES['File'], $folder);
             $file->OwnerID = $this->Member()->ID;
             $file->write();
             
             Director::redirectBack();
             return;
          }

    In this way I'm able to create a folder depending on a project name if it doesnt exist yet.
    However, this sets the folder name and 'filename' of it, but it doesnt set the folder 'Title', as used in the lefthand site of the cms in files section. That just stays 'new folder'.

    Is there a way to set this as well, without having to hack it?

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Setting folder 'title' Link to this post

    Solved by adding

    $item->Title = $part;

    to the findOrMake() method in Folder.php around line 32.


    Not sure if this is a bug or a feature, but let's hope what I did doesn't break anything

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