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.

General Questions /

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

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

create new assets folder problem


Go to End


3 Posts   2344 Views

Avatar
martimiz

Forum Moderator, 1391 Posts

21 August 2009 at 10:01pm

Hi all,
When creating a new assets folder in the Files & Images section, it is automatically created as Uploads/NewFolder/. When I then change the folder title and click save foldername, the URL field is not updated, and the fysical folder is still called 'NewFolder'. I then need to reload the section for the url field to be updated, so I can save it and actually change the fysical foldername.

I'm using 2.3.3. Can anyone maybe confirm this?

Avatar
martimiz

Forum Moderator, 1391 Posts

23 August 2009 at 1:38am

Edited: 23/08/2009 1:54am

It's weird - for some reason it now suddenly works fine. Don't want to know why, hope it stays that way :-)

[EDIT] No, there's still a problem - it works fine in the default language, but it fails when the cms is set to a different language (tried several). Maybe something gets translated that shouldn't be?

Avatar
martimiz

Forum Moderator, 1391 Posts

23 August 2009 at 7:14am

Got it (a ticket exists): it's a little bug where you can't have spaces or other illegal characters in the default foldername. Quick fix: adapt the default folder name in /cms/lang/xx_XX.php (remove spaces):

$lang['xx_XX']['AssetAdmin']['NEWFOLDER'] = 'xxxxx';

Cause of the problem:
In cms/code/AssetAdmin.php - line 488, function AddFolder() the fysical folder is created first, after that the Folder object is created and written to database, in which process the foldername is sanitized, replacing spaces by '-'. The folder object now doesn't reflect the fysical folder. Fix: reverse the order and use the sanitized foldername to create the fysical folder

line 494

    ...
    if(!$parentObj || !$parentObj->ID) $parent = 0;
}
// move creation of the folderobject
$p = new Folder();
$p->ParentID = $parent;
$p->Name = $p->Title = $name;

// use the folder's name to create the filename
if(isset($parentObj->ID)) $filename = $parentObj->FullPath . $p->Name();
else $filename = ASSETS_PATH . '/' . $p->Name();
...