Forum

Thread tagged as: Question, Runway

Editor select collection for display on page

Hi,

I have a really simple function on a Runway page that looks like this:

perch_collection('Things', [
   'template' => 'collections/display'
]);

I would like to use this page as a master page, and allow the editor to add new pages and select different collections to be used (to replace Things in the example above). What is the best way to give them a select box to choose the collection to be displayed on that page?

Many thanks

Mike

Mike Harrison

Mike Harrison 37 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can do that. The arguments are just strings, so they can be hardcoded or they can be dynamic if you choose.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

You can use a region to allow editors to choose the collection they want to display:

$collection = perch_content('Collection', true);

perch_collection($collection, [
    'template' => 'collections/display',
]);

As for the select field, I don't think there's an out-of-the-box select field that gets you a list of all the collections. If you know what the collections are, you can use a normal select field and hardcode the values:

<perch:content id="collection" type="select" label="Collection" options="Things, My Other Collection, Another Collection" />