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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Setting folder 'title'


Go to End


2 Posts   1310 Views

Avatar
dio5

Community Member, 501 Posts

15 June 2008 at 8:38am

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?

Avatar
dio5

Community Member, 501 Posts

19 June 2008 at 9:38am

Edited: 19/06/2008 9:53am

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 :)