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

Feature Request: Support drafts and live preview with element api #43

Closed
keithmancuso opened this issue May 27, 2017 · 17 comments
Closed

Comments

@keithmancuso
Copy link

We are working on a site that's built in VueJs and loads all its data via the element api. The big downside that we have found is there doesn't seem to be a way to support sharable draft urls or live preview which is a big bummer for our clients

Would there be anyway to support the same sort of "token?=" params for the for the element api? We could do the work to handle the rest assuming there was some way to get the preview and/or draft data via the api

@brandonkelly
Copy link
Member

Related to craftcms/cms#1489

@narration-sd
Copy link

narration-sd commented Jul 8, 2017

Definite support for the direction of this FR -- as ran into the same specific as @keithmancuso.

I'm thinking along the lines however of live preview tokens giving changed-element information that would allow js in the template to trigger a Vue event. This would handle the element api situation fully and efficiently, but also many more possible situations it seems clear.

Might this give some ideas for handling craftcms/cms#1489 and related as well?

@Radiergummi
Copy link

@keithmancuso have you found a solution to this? I'm in the exact same situation right now. I'm currently considering defining a new HTTP adapter in an inline script block that returns the current entry content for API requests, but that'd be a pretty hideous solution...

@tylerbrostrom
Copy link

TL;DR: "Gimme! Gimme! I want it! I want it!"

Craft is hands-down one of the most thoughtfully put together content authoring experiences out there. To me, choosing Craft is a no-brainer.

It is a bummer, though, that headless Craft doesn't support drafts and live preview. I want to use Craft for all the projects, but I also want to maintain the excellent authoring experience that is the mark of a traditional Craft project.

I have faith that as a headless CMS architecture becomes more and more standard, the great people behind Craft will answer. Thanks @brandonkelly for all of Pixel & Tonic's work. Sorry for complaining about the wifi!

@brandonkelly
Copy link
Member

@bro-strummer You had me at the Louis CK link.

Just released Element API 2.5 for Craft 3, which supports entry drafts & versions.

(Live Preview support for drafts & versions will require craftcms/cms#1489, slated for 3.1.)

@narration-sd
Copy link

narration-sd commented Oct 31, 2017

Well, now we know how to appeal...and that clip feels pretty relevant to a lot of things, doesn't it.

Happy to insta-report that Element API continues to work with some sufficiently wild things I'm doing with it, also.

@narration-sd
Copy link

p.s. Hoping same for #1489.

@tylerbrostrom
Copy link

Dreams do come true! Thanks @brandonkelly!

@mattandrews
Copy link
Contributor

@brandonkelly thanks so much for your work on this! We really needed this feature, fantastic to see it go live! Really appreciate the work that went into this. 💯

@spotd
Copy link

spotd commented Jan 23, 2018

Just seen that live preview support has been moved to 4.0 (#1489) ? I need live preview for a lot of react projects this year using element api. Is there any way around this?

@narration-sd
Copy link

narration-sd commented Jan 23, 2018

@spotd Live Preview itself is present and working on Craft 3. I believe what's put off is support for it in Multisite cases.

I presume it would presently continue to work on the default site when there are others, if haven't tested that -- @brandonkelly can answer that intention. Is Multisite Live Preview what you need?

for React or Vue, though, Multisite or not, you'd need more than the built-in Live Prevue can deliver. I'm more than a little on that case, and it might be interesting to chat a little about React needs.

Can you DM me via @narration_sd on the Craft Slack, where emails can be exchanged to make a conversation comfortable?

@dictions
Copy link

dictions commented Jun 6, 2019

@narration-sd do you have any info on getting a $draftId or $versionId` to the element API calls?

I can't find any docs on getting that info from the live preview token. Nor on the getting live preview entry data into the element API.

@narration-sd
Copy link

@dictions I just checked up above, and Brandon posted a link early to doc which should handle your $draftId etc., looks like...

https://github.com/craftcms/element-api#entry-drafts-and-versions

live preview in the element api would be a more recent case; not aware if it's implemented

@chrishentges
Copy link

Is this not a thing anymore? All of the documentation links don't lead to a section for drafts and versions.

@Mmasson-01
Copy link

Is this not a thing anymore? All of the documentation links don't lead to a section for drafts and versions.

https://github.com/craftcms/element-api/tree/2.5.4

@brandonkelly
Copy link
Member

The old draft/version support has been removed since Craft 3.2+ is capable of returning drafts and revisions via normal entry queries, using drafts, draftId, draftOf, revisions, revisionId, and revisionOf` params.

@xmarkclx
Copy link

Hello everyone! I found out a way to support live previews with element API.

Just add token query string, that's it!

&token=xxxxx

Just posting here in case it will save people's time as it wasted a few of mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests