Jump to:

22977 Posts in 11657 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » create new assets folder problem

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
Go to End
Author Topic: 1111 Views
  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    create new assets folder problem Link to this post

    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?

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: create new assets folder problem Link to this post

    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?

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: create new assets folder problem Link to this post

    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();
    ...

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