3

After updating to 2.6.2973, saving any entry fails, resulting in an Internal Server Error: "Could not resolve the subpath '{slug}'".

I've read the similar errors on here which trace back to Matrix Asset objects and dynamically-named folders, though I'm not using any dynamically-named folders, and I can't tell where it's pulling {slug} from, and/or what's causes the issue. I've gone through and double-checked and resaved both asset directory and field configurations.

The log again points in the direction of the Matrix Asset, and refers to the folder id "1" -- a Local Source which has both the System Path and URL completely hardcoded. The top of the trace looks like so:

#0 /[directory-path]/craft/app/fieldtypes/AssetsFieldType.php(707): Craft\AssetsFieldType->_resolveSourcePathToFolderId('1', '{slug}', true)
#1 /[directory-path]/craft/app/fieldtypes/AssetsFieldType.php(327): Craft\AssetsFieldType->_determineUploadFolderId(Object(Craft\Model))
#2 /[directory-path]/craft/app/services/ElementsService.php(1618): Craft\AssetsFieldType->onAfterElementSave()
#3 /[directory-path]/craft/app/services/MatrixService.php(778): Craft\ElementsService->saveElement(Object(Craft\MatrixBlockModel), false)
#4 /[directory-path]/craft/app/services/MatrixService.php(882): Craft\MatrixService->saveBlock(Object(Craft\MatrixBlockModel), false)
#5 /[directory-path]/craft/app/fieldtypes/MatrixFieldType.php(533): Craft\MatrixService->saveField(Object(Craft\MatrixFieldType))

This error stalls all the client's content entry, so I hoping for any additional insights or tips. Thanks so much.

3
  • The stack trace indicates you've got an Assets field inside of a Matrix field with an upload folder location set to {slug}. Are you sure you're looking at the correct Matrix field/Asset field combination?
    – Brad Bell
    Commented Apr 18, 2017 at 21:00
  • That was it, Brad -- I hadn't realized I set a {slug} subfolder within the Matrix/Asset field, which needed to be {owner.slug}. Thank you!
    – Marcus
    Commented Apr 18, 2017 at 21:43
  • Glad to help! Will go ahead and add it as an official answer.
    – Brad Bell
    Commented Apr 18, 2017 at 21:44

2 Answers 2

6

If you're setting an dynamic upload folder location for an Assets field inside of a Matrix field, you need to preface things like {slug} with {owner.slug}.

See the note about dynamic subfolders on an Assets field inside of Matrix here: https://craftcms.com/docs/assets-fields#dynamic-subfolder-paths

1
  • Glad this question was on here. Just had the same issue, where dynamic subfolders were working for standard fields, but not Matrix. Commented Oct 10, 2017 at 12:13
1

I found issue using {slug} in Global when sharing same asset field. Ended up leaving {slug} in entries field and using {id} for Global asset field (created new field), not sure if there is a better way to use Asset in global

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.