Fetching multiple pages with different IDs with single entry via blueprint

Good morning everyone,

I’m using following snippet to call a special page from database (datenbank)

$transitcode = $data->transitcode();
$items = page('datenbank')->children()->filterBy('template', 'document')->filterBy('documentidentifiercode', '*=', $transitcode);
foreach($items as $item): ?>
    <?= $item->title()->html() ?>
<?php endforeach ?>

In blueprint there is an form to submit (internaly called) transitcode, it looks like U-02-2010. The snippet above displays than the title of that specific page with code U-02-2010.

Is there a possibility to submit multiple ID-s via transitcode? How should be the code above modified to make that?

I would love to enter in same form something like this (separated with comma and new line):


the snippet would than call the titles of three pages with transitcode-IDs i submited. :slight_smile:

I’d store them as a comma separated list (use a multi-select field or tags field to enter the data)

transitcode: U-02-2010, U-02-4020, U-04-6070

Then in your snippet:

$transitcodes = $data->transitcode()->split(); // this gives us an array of the transit codes
$items = page('datenbank')->children()->filterBy('template', 'document')->filter(function($item) use($transitcodes) {
  // within the callback, we check of the item's identifier is in the array and return if true
  return in_array($item->documentidentifiercode(), $transitcodes);
1 Like

Hello @texnixe,

thanks for quick reply!

I’ve tried that, I’m getting a parse error, debugger says

ParseError thrown with message "syntax error, unexpected ';', expecting ',' or ')'"

Here is how I’ve integrated it in the snippet: https://pastebin.com/RQUJ1fdD

Corrected above.

It works great! Thanks