Contentful logo

Contentful Community

How to structure Content Preview URL with references

Hi

I’m struggling with the syntax for setting up the preview url. My Content Model looks like this:

…{
“id”: “slug”,
“name”: “Slug”,
“type”: “Symbol”,
“localized”: false,
“required”: true,
“validations”: [
{
“regexp”: {
“pattern”: “^[a-zA-Z0-9]+(?:-[a-z0-9]+)*$”,
“flags”: null
}
}
],
“disabled”: false,
“omitted”: false
},
{
“id”: “parentSlug”,
“name”: “Parent Slug”,
“type”: “Link”,
“localized”: false,
“required”: false,
“validations”: [
{
“linkContentType”: [
“slug”
]
}
],
“disabled”: false,
“omitted”: false,
“linkType”: “Entry”
},…

My ContentModel for the object Page has a ‘slug’ (shortText) and a reference to an object ‘parentSlug’ which contains a field name(also String)

So to clarify my URL topology looks like this: /parentSlug/slug
The field ‘slug’ is retrieved via {entry.fields.slug} which is normal text. But how do i access the text within a referenced (NOT linkedBy) element?
How to write this in the Page Preview on the ContentModel Page? I couldn’t find anything on the documentation here: /setup-content-preview/

This is my current guessing (based on my OOP understanding) but it doesn’t work.
domain.com/{entry.fields.parentSlug.fields.slug}/{entry.fields.slug}

Any help is appreciated, Thank you in advance.

Unfortunately it is not possible to reference child references in a content preview URL at the moment.

What a bummer this is still not implemented, but at the very least, the sidebar and / or the linked documentation should reference this limitation. All I can glean from a child reference in a content preview URL is an array with a sys property and a child id property.