-2

dears,

am building website using apostrophe cms and i have news page in my site which contain all news and when you click any news it will redirect you to single news page , however i already made everything above but my issue that i want to display only latest 3 news in homepage , is there any way or someone can give me hint or help please.

my news i build it like below

i make news folder with index page include my schema inside lib-modules-news

and make news-pages also inside

lib-modules-news-pages have index.html and widget.html

now i want to render only last new 3 news inside home.html

thanks in advance

ali alroomi
  • 9
  • 1
  • 4

1 Answers1

2

There is an out-of-the-box functionality that handles this. You want to create an apostrophe-pieces-widgets widget extension. You will then be able to display your new pieces in three ways.

  1. Reverse chronological by publish date (last X posts) (This is represented by the All option)
  2. Hand curated
  3. Pieces of this type that have a tag of X

You want to follow this part of the Docs https://docs.apostrophecms.org/apostrophe/tutorials/getting-started/reusable-content-with-pieces#displaying-pieces-with-widgets

See real code examples in the Apostrophe Open Museum repo, specifically the blog/article module extensions https://github.com/apostrophecms/apostrophe-open-museum

Stuart Romanek
  • 2,157
  • 1
  • 7
  • 9