Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setDefaultFolder creates wrong folder #19

Open
Zauberfisch opened this issue Sep 14, 2011 · 2 comments
Open

setDefaultFolder creates wrong folder #19

Zauberfisch opened this issue Sep 14, 2011 · 2 comments

Comments

@Zauberfisch
Copy link
Contributor

$file->setDefaultFolder('test');

this will create 'test', and store my files in test, but it also creates a folder named 'folder'.

@jonom
Copy link
Contributor

jonom commented Sep 26, 2011

I changed line 148 of KickAssetField.php to

$folder = $this->defaultFolder ? $this->defaultFolder : singleton('Folder');

this seems to work for me. The reason I think is that setDefaultFolder() already uses Folder::findOrMake() so a folder object was being passed as input here instead of a string.

@micahsheets
Copy link
Contributor

The problem seems to be caused by the BrowseLink() function.However to make it still work as intended, since $this->defaultFolder is actually a Folder Object and findOrMake needs string, the function needs to be written like this:

public function BrowseLink() {
    $folder = $this->defaultFolder
    // findOrMake requires a string for a path that is relative to the assets folder
        ? Folder::findOrMake(str_replace("assets/", "", $this->defaultFolder->Filename))
        : singleton('Folder');
    return Director::absoluteBaseURL() . "admin/files/select/{$folder->ID}";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants