{"action":"created","issue":{"url":"https://api.github.com/repos/locomotivecms/steam/issues/72","repository_url":"https://api.github.com/repos/locomotivecms/steam","labels_url":"https://api.github.com/repos/locomotivecms/steam/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/locomotivecms/steam/issues/72/comments","events_url":"https://api.github.com/repos/locomotivecms/steam/issues/72/events","html_url":"https://github.com/locomotivecms/steam/pull/72","id":164626529,"number":72,"title":"Add 'capture selected_object' and 'contents.selected_object'","user":{"login":"andrewclink","id":688916,"avatar_url":"https://avatars.githubusercontent.com/u/688916?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewclink","html_url":"https://github.com/andrewclink","followers_url":"https://api.github.com/users/andrewclink/followers","following_url":"https://api.github.com/users/andrewclink/following{/other_user}","gists_url":"https://api.github.com/users/andrewclink/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewclink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewclink/subscriptions","organizations_url":"https://api.github.com/users/andrewclink/orgs","repos_url":"https://api.github.com/users/andrewclink/repos","events_url":"https://api.github.com/users/andrewclink/events{/privacy}","received_events_url":"https://api.github.com/users/andrewclink/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-08T22:16:07Z","updated_at":"2016-08-09T15:28:47Z","closed_at":"2016-08-09T15:28:47Z","pull_request":{"url":"https://api.github.com/repos/locomotivecms/steam/pulls/72","html_url":"https://github.com/locomotivecms/steam/pull/72","diff_url":"https://github.com/locomotivecms/steam/pull/72.diff","patch_url":"https://github.com/locomotivecms/steam/pull/72.patch"},"body":"I find myself needing a \"featured product\"  or something similar regularly. I implemented something for a previous version of locomotive, but it's messy and I'm moving on. This is the beginning of reimplementing that functionality for the new version.\r\n\r\nTo use: assign a content_type and slug to a liquid variable:\r\n\r\n\t{% capture featured_product %}\r\n\t\t{{ contents.product.first.select }}\r\n\t{% endcapture %}\r\n\r\nFuture references to `contents.selected_object` (or whatever the variable was called) will result in a lookup of the specified object:\r\n\r\n        <h2>{{contents.featured_product.title}}</h2>\r\n\r\nI intend to implement a select field for the back office along the lines of `editable_model` (and I wish I could use that name), but I'm on a production schedule and this has to be good enough for now.\r\n\r\nI'm also probably not giving the depth-of-thought needed to fully understand variable lookup with regard to scopes and contexts; if there is a more efficient way to do what I'm trying to do please point me in the right direction and I'll revise it. For example, caching would probably be nice (does mongo do this behind the scenes?)"},"comment":{"url":"https://api.github.com/repos/locomotivecms/steam/issues/comments/238590466","html_url":"https://github.com/locomotivecms/steam/pull/72#issuecomment-238590466","issue_url":"https://api.github.com/repos/locomotivecms/steam/issues/72","id":238590466,"user":{"login":"did","id":8065,"avatar_url":"https://avatars.githubusercontent.com/u/8065?v=3","gravatar_id":"","url":"https://api.github.com/users/did","html_url":"https://github.com/did","followers_url":"https://api.github.com/users/did/followers","following_url":"https://api.github.com/users/did/following{/other_user}","gists_url":"https://api.github.com/users/did/gists{/gist_id}","starred_url":"https://api.github.com/users/did/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/did/subscriptions","organizations_url":"https://api.github.com/users/did/orgs","repos_url":"https://api.github.com/users/did/repos","events_url":"https://api.github.com/users/did/events{/privacy}","received_events_url":"https://api.github.com/users/did/received_events","type":"User","site_admin":false},"created_at":"2016-08-09T15:28:47Z","updated_at":"2016-08-09T15:28:47Z","body":"hi @andrewclink! Would that liquid code do the same?\r\n\r\n```liquid\r\n{% with_scope _id: <your_id_or_slug> %}\r\n{% assign featured_product = contents.products.first %}\r\n{% endwith_scope %}\r\n\r\n{{ featured_product.title }}\r\n```\r\n\r\nOkay, It might be a little too verbose. A better syntax but **not implemented** would be:\r\n\r\n```liquid\r\n{% assign featured_product = contents.products | filter: _id: <your_id_or_slug> | first %}\r\n```\r\n\r\nOther than that, you seem to miss a content entry picker in the page editing UI. That could be more than useful! If this is what you want, open an issue in locomotivecms/engine! thanks!"}}
{"actor":{"display_login":"did"}}