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

Asset objects aren't returned with all attributes set #1

Open
imjakechapman opened this issue Nov 3, 2014 · 2 comments
Open

Asset objects aren't returned with all attributes set #1

imjakechapman opened this issue Nov 3, 2014 · 2 comments

Comments

@imjakechapman
Copy link

I'm spitting back a single entry via the json_expand | raw twig function for Marionette to digest on initial page load.

This is the object that is given back for the entries mp3...

This field is attached to a matrix field that only allows 1 mp3 fields to be entered. The only available attributes is the slug.

"mp3":{ "0":{ "id":"5", "enabled":"1", "archived":"0", "locale":"en_us", "localeEnabled":"1", "slug":"thinkcraftcode-demo", "uri":null, "dateCreated":{ "date":"2014-04-04 08:13:30.000000", "timezone_type":1, "timezone":"+00:00" }, "dateUpdated":{ "date":"2014-04-04 08:41:21.000000", "timezone_type":1, "timezone":"+00:00" }, "root":null, "lft":null, "rgt":null, "level":null, "sourceId":"2", "folderId":"2", "filename":"thinkcraftcode-demo.mp3", "originalName":null, "kind":"audio", "width":null, "height":null, "size":"1488687", "dateModified":{ "date":"2014-04-04 08:13:28.000000", "timezone_type":1, "timezone":"+00:00" } }

But spitting it out with normal twig inside of a template gives me the full URI, not just a filename.

@imjakechapman
Copy link
Author

Just a quick update. This only happens when it's a matrix field asset. 😃

@keithmancuso
Copy link
Owner

hey jake, sorry for the issues. To be honest we sort of moved away from using this plugin internally for a number of reasons, the biggest of which was performance, since it was designed to output the entire object it really turned out to be really really slow.

For our internal projects we actually started using https://github.com/nfourtythree/craft-json-data which allows you to specify fields vs dumping the entire object. Nathan and I traded a lot of notes back and forth as were working and he ended up with a better approach i think.

I should also say the technique we've had the most success with is simply writing out the json in a template more like this: http://craftcms.stackexchange.com/questions/20/how-would-i-retrieve-channel-data-in-json-format/60#60

The last thing i'll share is you may also want to look at https://github.com/mattstauffer/craftcms-prune it seems to work a lot like Nathans json data plugin but just focused on filling out the object fields and using the standard | json_encode filter

I hope some of that helps

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

2 participants