Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Cannot get linked entries #57

Open
Battleaxe19 opened this issue Dec 5, 2017 · 1 comment
Open

Cannot get linked entries #57

Battleaxe19 opened this issue Dec 5, 2017 · 1 comment

Comments

@Battleaxe19
Copy link

Hey guys,

I'm having a difficult time retrieving the entries I need to retrieve. I have a contentful entry called aboutPage that contains two fields titled ourLeadership and ourStaff. Each of those fields contains multiple links to other entries called aboutPageStaff.

My metalsmith header contains this:
contentful:
entry_id: xaV2K7fvoWEkWCmqa04Sy
layout: base.html

Where the entry ID is for the specific aboutPage entry I'm getting.

I cannot find the right syntax to get at the aboutPageStaff data.

The aboutPage JSON preview looks like this:

{
"name": "About Page",
"description": "",
"displayField": null,
"fields": [
{
"id": "ourLeadership",
"name": "Our Leadership",
"type": "Array",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"aboutPageStaff"
]
}
],
"linkType": "Entry"
}
},
{
"id": "ourStaff",
"name": "Our Staff",
"type": "Array",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"aboutPageStaff"
]
}
],
"linkType": "Entry"
}
}
],
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "n4mniz0krvft"
}
},
"id": "aboutPage",
"type": "ContentType",
"createdAt": "2017-12-05T00:30:59.011Z",
"updatedAt": "2017-12-05T21:43:30.314Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "70A91lKqCD9LJIUA6M79k8"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "70A91lKqCD9LJIUA6M79k8"
}
},
"publishedCounter": 3,
"version": 6,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "70A91lKqCD9LJIUA6M79k8"
}
},
"publishedVersion": 5,
"firstPublishedAt": "2017-12-05T00:30:59.297Z",
"publishedAt": "2017-12-05T21:43:30.314Z"
}
}

And the aboutPageStaff content type looks like this:
{
"name": "About Page Staff",
"description": "Data for use on the About Page. Add these to the About Page content model. \n\nStaff Type determines if entry goes in the Our Leaders section, or the Our Staff section.",
"displayField": "name",
"fields": [
{
"id": "image",
"name": "Image",
"type": "Link",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"linkType": "Asset"
},
{
"id": "name",
"name": "Name",
"type": "Symbol",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false
},
{
"id": "staffDetails",
"name": "Staff Details",
"type": "Text",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false
},
{
"id": "staffType",
"name": "Staff Type",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
{
"in": [
"Leaders",
"Staff"
]
}
],
"disabled": false,
"omitted": false
}
],
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "n4mniz0krvft"
}
},
"id": "aboutPageStaff",
"type": "ContentType",
"createdAt": "2017-12-05T00:25:31.668Z",
"updatedAt": "2017-12-05T00:25:31.985Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "70A91lKqCD9LJIUA6M79k8"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "70A91lKqCD9LJIUA6M79k8"
}
},
"publishedCounter": 1,
"version": 2,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "70A91lKqCD9LJIUA6M79k8"
}
},
"publishedVersion": 1,
"firstPublishedAt": "2017-12-05T00:25:31.985Z",
"publishedAt": "2017-12-05T00:25:31.985Z"
}
}

@Khaledgarbaya
Copy link
Contributor

Hi @Battleaxe19,
Make sure to specify the include param to include all your reference in the response.
https://github.com/contentful/contentful-metalsmith/blob/master/docs/source-file-settings.md#include-optional

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

No branches or pull requests

2 participants