Closed p3sn closed 7 years ago
@p3sn can you share a snippet of code where you access the fields.
do you have something like {fields.referenceField.fields.fielName}
?
Hi @Khaledgarbaya ,
First I use this each:
{{#each data.fields.layoutOfPage}}
within the each, I use a partial:
{{> partialLayout}}
In the partial I can load values like:
<h2>{{ this.fields.title }}</h2>
<h3>{{ this.fields.subtitle }}</h3>
And also:
{{#each this.fields.cards}} or {{#each this.fields.faq}}
Which are related (relationship) to a content type cards and faq. But the only value {{this}} has within the last each loop is:
"sys": {
type: Link
linkType: Entry
id: 5Dc6Gl2ICW6k08AQkU8cwY
}
I think this is normal behaviour, but I used to work with the angular version before and including up to 10 worked like a charm.
Now I'm trying to get the same result, but as a static website with metalsmith.
Thanks, Regards, Peter
Hi @p3sn,
Is the data.fields.layoutOfPage
and array of references ? or a dictionary ?
can you try to access the first element of it without the each.
like data.fields.layoutOfPage[0].fields
.
Hi @Khaledgarbaya ,
In contentful it's a reference within a reference. I can't access it without the each. I only get the sys object of those references. As mentioned in the documentation in here: https://www.contentful.com/developers/docs/concepts/links/#link-values-in-entries I assume this is related to my case: I only get link sys-data and not the actual content of the linked entry.
Regards, Peter
@p3sn the plugin is using the javascript SDK which is do the link resolution for you
@Khaledgarbaya, I understand.
That's why I added include: 10. And I should get 10 levels deep back, right?
Regards, Peter
Just to clarify: This works: {{ data.fields. layoutOfPage.[0].fields.title }}
One level more does not work: {{ data.fields. layoutOfPage.[0].fields.cards.[0].fields }} it results in null / nothing
But sys does work: {{ data.fields. layoutOfPage.[0].fields.cards.[0].sys }} it results in [object Object]
Regards, Peter
~hmm, that should work unless there is a pagination problem, for example some of the includes didn't make to the current page of the payload. I think the plugin should maybe expose some configuration on how to deal with pagination. By default the API is returning 100 record per page and it can be set to max 1000.~
Hi @Khaledgarbaya,
In the angular version (which should work almost the same), I didn't hit the limit of 100. I don't have that many records. I also narrowed down the number of entries by using content_type: defaultPage.
So I'm almost sure the limit isn't causing this issue. I also changed limit to 1000 to double check. Can it me that include isn't an option, because it's not mentioned in here.
@Khaledgarbaya Ah damn, that was it! I started with downloading the metalsmith-contentful example on github. I updated contentful-metalsmith ^0.7.0 → ^0.9.0 and now it works like a charm.
Thanks a lot for your help!
Regards, Peter
Sweet!
I started with downloading the metalsmith-contentful example on github
Can you point us to the location where you found this fork referenced? :)
Anyways cool it works now!
It's the example mentioned on the homepage of contentful-metalsmith github. Here is the link: https://github.com/contentful-labs/contentful-metalsmith-example
@p3sn @stefanjudis the example is now up to date also
Hi All,
I have set include to 10, but still I don't get all data. At a depth of 3, I only get the .sys data.
Do you have any idea why I don't get all content of all objects?
Regards, Peter