4

I have a Matrix field with two blocks. Each block has an assets field that I'm trying to set to restrict to uploads to a single folder and setting the upload location to {slug}. Basically what I'm trying to do is set up a main folder for my portfolio. I want to be able to upload images for each entry and have them placed in a folder with the same name as the entry so whenI look in Assets I see something like:

Portfolio
-- project 1 entry name
-- project 2 entry name
...
-- project 17 entry name
-- project 18 entry name

When I upload the file in my entry form no subfolders are created. I have tried a few things to remedy the problem to no avail. I've set permissions to 777 and have tried placing a / before {slug} because the fileSystemPath variable doesn't have a trailing slash in my general.php config file. Any other issues that might cause this?

1
  • Stuart, I'm not at all certain you can evaluate {slug} at that point. Especially not if you're uploading from the CP. I suggested elsewhere about assuring a full file system path, but by your naming it appears you've done that. Maybe if you explain a little more specifically what you're doing, one of us can give an idea. Or you'll make it easier for the travelling duo... Commented Jun 28, 2014 at 4:42

1 Answer 1

6

Since you're inside the context of a Matrix block, you'll want to use:

{owner.slug}

instead of:

{slug}

More information on that http://buildwithcraft.com/docs/assets-fields#dynamic-subfolder-paths

2
  • This makes sense but I would have never thought this was necessary. Are there instances where the slug isn't referencing the parent? Commented Jun 28, 2014 at 12:45
  • Sure... when it's not inside of Matrix. :)
    – Brad Bell
    Commented Jun 28, 2014 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.