Forum

Thread tagged as: Question, Discussion, Runway

Suggestions: Multiple collections or single collection approach?

Hey,

Little bit rusty, just wondering the best way to approach a particular idea in an upcoming project. I am using runway.

I have a section called Journal which will contain both news articles and stories which will be laid out in chronological order but styled differently depending on whether its an article or story.

The news article will contain standard article fields and use an article specific template. The stories will contain fields like story, author image, author name and use a story specific template.

I'm not sure whether it would best to use two separate collections, one to hold articles and one to hold stories and if possible use a call on the journal page to display the items from each mixed together in chronological order?

or

Use one collection to hold both articles and stories and if possible select the template to be used when creating a new item and use categories to differentiate between article or story? Although I'm not sure collections has the ability to select template like the blog app does.

or

Use the blog app and use two post types or setup multiple blogs to create a set of articles and stories.

Choices, choices - any suggestions would be appreciated.

Cheers

Marc Sanders

Marc Sanders 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I would use two collections.

Is it possible to return content from multiple collections with one call?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can do that.

How would you pass in the name of two collections and return the results, I can't seem to see the option in the function docs.

Duncan Revell

Duncan Revell 78 points
Registered Developer

I think it's an array of collection names. Check out the docs for perch_content_custom - use the same method as returning multiple regions.

Cool, I'll give it a go, that's great - cheers

For reference, I managed to pull in content from two collections using the following method:

    perch_collection(['Articles','Stories'], [
        'template' => 'items.html',
        'sort' => 'date',
        'sort-order' => 'DESC'
    ]);

Although within my items.html template, would there be a way of determining whether item is an article or a story output the content differently?

Duncan Revell

Duncan Revell 78 points
Registered Developer

In your items.html template, add a <perch:showall /> to show you all the data available. There might be something in there you can use.