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

Many content types on one page #47

Open
pangorgo opened this issue Feb 27, 2017 · 2 comments
Open

Many content types on one page #47

pangorgo opened this issue Feb 27, 2017 · 2 comments

Comments

@pangorgo
Copy link

Is it possible to list two or more content types on one page?
Lets say I have events and news content types and I want both of them listed on one page.

@Khaledgarbaya
Copy link
Contributor

Hi @pangorgo,
I didn't try this but you can specify content_type to * but then you will need to do more filtering

---
title: metalsmith-contentful file
contentful:
  content_type: *
  layout: post.html
layout: posts.html
---

One better suggestion, you can have on content_type called page for example and inside of it, you have a reference field that points to either event content_type or news content_type. so this way you can specify one content_type: page and you can display content of both events and news

---
title: metalsmith-contentful file
contentful:
  content_type: page
  layout: post.html
layout: posts.html
---

and inside you template you check if the reference name for example is 'event' you display something and if the name is news you display something else

{{#if fields.tage.name === 'events'}}
// display events data
{{/if}}

@stefanjudis
Copy link
Contributor

👍 for a page model.

What you could do also (depending on your use case) you could put several calls in the common section.

https://github.com/stefanjudis/stefan-judis-website/blob/master/build.js#L50-L77
https://github.com/contentful/contentful-metalsmith/blob/master/docs/global-settings.md#common-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

3 participants