Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Create collection based on page routes

Solved by pamtbaau View solution

Started by Jamie Pickett 6 years ago · 2 replies · 432 views
6 years ago

I have a folder of content that contains over 500 items. Instead of having the .md file iterate over items: '@self.children' limited to 6 per page, I am looking to see if it is possible to specify 10 pieces of content to feature for the item collection? If I know the slugs of the particular items, can I make a collection from that?

last edited 07/08/20 by Jamie Pickett
6 years ago Solution

@pickettj, If I understand the question correctly, a combination of the following two features of Page Collections might provide you the desired result: A collection of pages specified by their route.

  • @page.self or @page.page - Collection of just the specific page

    This collection takes a slug route of a page as an argument and will return collection containing that page (if it is published and non-modular ):

    YAML
    content:
    items:
    '@page.self': '/blog'
    
  • Complex Collections

    You can also provide multiple complex collection definitions and the resulting collection will be the sum of all the pages found from each of the collection definitions. For example:

    YAML
    content:
    items:
    - '@self.children'
    - '@taxonomy':
    category: [blog, featured]
    

Example of the combination of the two features:
The following page defines a collection containing two items of a blog specified by their route:

YAML
content:
  items:
    - '@page.self': '/blog/hero-classes'
    - '@page.self': '/blog/london-at-night'
6 years ago

@pamtbaau:
@page.self

Thanks for your response. That will do what I am looking for.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
3 90 1 hour ago
Support · by Anna, 3 days ago
2 92 22 hours ago
Support · by Justin Young, 23 hours ago
1 40 23 hours ago
Support · by Duc , 1 week ago
2 98 6 days ago
Support · by Colin Hume, 1 week ago
2 90 6 days ago