Cms: Get standard uid for preview target

Created on 7 Jan 2020  路  3Comments  路  Source: craftcms/cms

I have a preview target like this:

@previewUrl/live-preview/fooBar/{uid}

Instead of giving me the uid of the entry, I am getting some weird uid (maybe the uid of the draft). Is there a way to get the standard uid?

question

All 3 comments

Yeah, it鈥檚 the draft鈥檚. Change to {sourceUid} and it will return the real entry UID.

@brandonkelly, thanks! Is that documented anywhere?

It is now :)

https://docs.craftcms.com/v3/sections-and-entries.html#preview-targets

If you want to include the entry鈥檚 ID or UID in a preview target URL, use {sourceId} or {sourceUid} rather than {id} or {uid}, so the source entry鈥檚 ID or UID is used rather than the draft鈥檚.

Was this page helpful?
0 / 5 - 0 ratings