Content preview URLs - get field value of linked model

Hello.

I’m trying to configure preview in my online environment.
I have Page content model with slug field and Resource content model with pageGroup field (accepts only the Page model).
The issue is to set preview for the resource model as //host/entry.pageGroup.slug/entry.id
When I’m getting the id of the pageGroup in the way
//host/{entry.fields.pageGroup.sys.id} - it works right.
When I’m trying to get the slug field of the Page group in the way
//host/{entry.fields.pageGroup.fields.slug} - there is an error
//host/fields.pageGroup.fields.slug_%20NOT_FOUND
‘entry’ in these examples is the Resource model.
Is there any possibility to have a slug value of the page model from the resource?

If it’s not very clear, feel free to ask me more questions, I will try to explain the issue in more details.

Hi Andrii, I am Alma from Contentful support :wave:

There are some limitations in the default content preview function, and you just observed one: it doesn’t resolve content of linked entries :sweat_smile:

As a workaround, you might want to use Content Preview API to build you own preview site. Content Preview API (https://www.contentful.com/developers/docs/references/content-preview-api/) works has a similar setup as Content Delivery API, so you can leverage on your existing application to create the preview site.

I would very much want to see this feature. I’m modelling a Page that links to an Application that contains meta-data such as hostname information. I would like the preview to be able to show https://{entry.fields.application.previewhostname}/{entry.fields.slug}.

The documentation on the sidebar is a bit lacking to be honest, for example it mentions linkedBy attribute but does not explain which incoming link it refers to.

1 Like

Hi @olli.kasari, unfortunately it has been a design choice to allow a fixed preview URL, since it’s more reliable and more secure (you could have different environments, each one of the them pointing to the proper hostname / test, staging, production).

But I would like to ask you if you could link to which documentation you are referring to, so that I can try to clarify your doubts.

Hi Alma!

I’m facing the same problem as the original poster. Being able to link entries to others is a powerful feature of Contentful, which fits perfectly GraphQL, but not being able to resolve them in the default content preview is very hindering.

I’m developing the website of my club, but I won’t be writing the posts. Those who will write them are not experienced with coding, and I’d really like them to be able to click on the button “Open preview” so that they can preview their changes. It will be too cumbersome to set up a custom preview environment, especially because I’ll have to tell everyone that they must not use the big button “Open preview”, but go to another website.

Is there any plan in the future to allow the default content preview to resolve the content of linked entries? It’d be wonderful! :smiley:

Agree with the other posters, this would be a very useful feature, and if it’s not available, the documentation should clearly state that. We’ve spent quite a bit of time trying to figure out how to make it work before finding this post.

What we want to do (category is a reference):

https://staging.oursite.com/events/{entry.fields.category.fields.slug}/{entry.fields.slug}

The result when clicking on preview:

https://staging.oursite.com/events/fields.category.fields.slug_%20NOT_FOUND/slug-for-entry

But, when you use {entry.fields.category.sys.id}, the sys.id of the referenced entry renders correctly…not that it’s helpful, but it’s strange that the sys object is returned, but fields are not.

We’re migrating to Contentful from a legacy site that uses category slugs in the path, so in order to make our migration as painless as possible and to retain SEO value, we’re keeping the same URL structure. We tried doing the right thing data-structure wise by creating a normalized Category reference instead of a category text field, but the preview limitation may cause us to switch to a text field instead. That’s a very frustrating workaround in a system that revolves around the use of referential data structures.

@Alma any chance this enhancement is on the roadmap or should we give up?

1 Like

Hi @themeateater, I checked our roadmap (which is per quarter), and unfortunately I don’t have updates about the Content Preview feature yet; I will make sure to send another feedback to the team.

What I’d like to mention though, is the Gatsby Cloud App our team developed. Maybe it could suit your use case as well: https://www.contentful.com/marketplace/app/gatsby/

@Alma is there any update on this, we are also looking for the feature mentioned by @themeateater regarding using category slugs.

Any updates on this? At the very least, can a note be added to the documentation calling out this limitation?

Still waiting for this feature…

My team is also very much in need of this feature. Is there any way we can get an update?