{"action":"created","issue":{"url":"https://api.github.com/repos/benjamminf/craft-neo/issues/22","repository_url":"https://api.github.com/repos/benjamminf/craft-neo","labels_url":"https://api.github.com/repos/benjamminf/craft-neo/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/benjamminf/craft-neo/issues/22/comments","events_url":"https://api.github.com/repos/benjamminf/craft-neo/issues/22/events","html_url":"https://github.com/benjamminf/craft-neo/issues/22","id":156750860,"number":22,"title":"Bug: Using asset field with {slug} as upload location","user":{"login":"johanneslamers","id":4696315,"avatar_url":"https://avatars.githubusercontent.com/u/4696315?v=3","gravatar_id":"","url":"https://api.github.com/users/johanneslamers","html_url":"https://github.com/johanneslamers","followers_url":"https://api.github.com/users/johanneslamers/followers","following_url":"https://api.github.com/users/johanneslamers/following{/other_user}","gists_url":"https://api.github.com/users/johanneslamers/gists{/gist_id}","starred_url":"https://api.github.com/users/johanneslamers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanneslamers/subscriptions","organizations_url":"https://api.github.com/users/johanneslamers/orgs","repos_url":"https://api.github.com/users/johanneslamers/repos","events_url":"https://api.github.com/users/johanneslamers/events{/privacy}","received_events_url":"https://api.github.com/users/johanneslamers/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/benjamminf/craft-neo/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/benjamminf/craft-neo/milestones/1","html_url":"https://github.com/benjamminf/craft-neo/milestones/1.3.0","labels_url":"https://api.github.com/repos/benjamminf/craft-neo/milestones/1/labels","id":1775451,"number":1,"title":"1.3.0","description":"","creator":{"login":"benjamminf","id":6325915,"avatar_url":"https://avatars.githubusercontent.com/u/6325915?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamminf","html_url":"https://github.com/benjamminf","followers_url":"https://api.github.com/users/benjamminf/followers","following_url":"https://api.github.com/users/benjamminf/following{/other_user}","gists_url":"https://api.github.com/users/benjamminf/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamminf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamminf/subscriptions","organizations_url":"https://api.github.com/users/benjamminf/orgs","repos_url":"https://api.github.com/users/benjamminf/repos","events_url":"https://api.github.com/users/benjamminf/events{/privacy}","received_events_url":"https://api.github.com/users/benjamminf/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":1,"state":"open","created_at":"2016-05-19T03:18:26Z","updated_at":"2016-06-10T07:10:08Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-05-25T13:28:42Z","updated_at":"2016-06-10T07:10:08Z","closed_at":"2016-06-10T07:10:08Z","body":"Hi Benjamin.\r\n\r\nFirst of all, LOVE the plugin. It's how the Matrix should work by default. \r\nBut I'm having a error when uploading an asset file (S3) with a preset upload location with {slug} as variable. The error is only showing when using the field inside Neo. As standalone field it's uploading fine.\r\n\r\nThis is the error: Could not resolve the subpath “{slug}”.\r\n\r\n![screencapture-portfolio-craft-dev-admin-entries-case-4-925-1464182877977](https://cloud.githubusercontent.com/assets/4696315/15541559/56917cea-228d-11e6-9ecc-63462b99dd09.png)\r\n"},"comment":{"url":"https://api.github.com/repos/benjamminf/craft-neo/issues/comments/225109509","html_url":"https://github.com/benjamminf/craft-neo/issues/22#issuecomment-225109509","issue_url":"https://api.github.com/repos/benjamminf/craft-neo/issues/22","id":225109509,"user":{"login":"benjamminf","id":6325915,"avatar_url":"https://avatars.githubusercontent.com/u/6325915?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamminf","html_url":"https://github.com/benjamminf","followers_url":"https://api.github.com/users/benjamminf/followers","following_url":"https://api.github.com/users/benjamminf/following{/other_user}","gists_url":"https://api.github.com/users/benjamminf/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamminf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamminf/subscriptions","organizations_url":"https://api.github.com/users/benjamminf/orgs","repos_url":"https://api.github.com/users/benjamminf/repos","events_url":"https://api.github.com/users/benjamminf/events{/privacy}","received_events_url":"https://api.github.com/users/benjamminf/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T07:10:08Z","updated_at":"2016-06-10T07:10:08Z","body":"I've found that in order to properly fix this, I'd have to override a few hundred lines of core code and monkey patch the front-end Javascript, which is far from ideal.\r\n\r\nAside from creating a duplicate field just for Neo blocks, I've come up with another way of accomplishing this. Since you can use anything Twig provides in the asset fields directory fields, you can use this to your advantage.\r\n\r\nTo begin, `{slug}` can actually be replaced with `{{ object.slug }}`. This shows that we have the ability to use double brace tags, which means we can use logic. So the idea is to check to see if `object` is a Neo block, and if so, use `object.owner.slug` instead.\r\n\r\nBad news is, there's no built-in way to detect this. But since this is for a plugin, I've just implemented a Twig extension into Neo (to be available in the next release) that allows you to test if some value is a Neo block model. Now we can do this: `{{ object is neoblock ? object.owner.slug : object.slug }}`\r\n\r\nYes, it's a more verbose than `{slug}`, but it's the cleanest solution possible."}}
{"actor":{"display_login":"benjamminf"}}