Preview Custom Block - show data from other page

On a page with the layout field I want to show custom-blocks-data from another page. In the panel I can’t get the block preview to show this data (from another page).

use case
I made a custom block type (a meditation course) with two fields in it. I created a page with this block type (its a meditation-course with two dates in each block-item), so the user has a dedicated page to enter and edit multiple items of this data. Works very nice. All data of this type is shown on one page.

To show the data of this block type on a page with a layout (like the about-us page in Starterkit), I need a block type to add it to the page in the Panel.

Question
How can I get the data from the blocks in the other page into the block preview on the page with a layout?

what I already tried
I have used Custom block examples | Kirby CMS as an example.
I have modified the site/plugins/block-factory/snippets/blocks/faq.php to get the right data into the panel but that was not the solution, it only changed the output to the website.

I clearly have to edit the vue code in (this example) the index.js file. This is the contents of the file from the block factory examples.

My Questions
What do I have to do to get data from another page into this preview?
Is it possible to get data from somewhere else in Kirby into the blocks-preview?
If I want to store block-data on one page and re-use it on another (layout) page maybe I need to use a different way to implement this in Kirby?

Hope someone can shed some light on the subject,
Thanks!
René

The index.js file I have been experimenting with:

panel.plugin("cookbook/block-factory", {
  blocks: {
    faq: `
    <div @dblclick="open">
      <h2 class="k-block-type-faq-heading" v-html="content.headline"></h2>
      <div v-if="content.faq.length">
        <details v-for="(item, index) in content.faq" class="k-block-type-faq-item" :key="index">
          <summary>{{ item.question }}</summary>
          <div v-html="item.answer"></div>
        </details>
      </div>
      <div v-else>No questions yet</div>
    </div>
  `
  }
});

Yes, but this is more complex and you have to use an API query, similiar to the card example in the block recipe: Custom block examples | Kirby CMS

1 Like

Thank you!
Although it was a lot of trial and error for me, I managed to alter the card example and get results. I parsed the data into an object and added HTML.

Question about two times having the same HTML
I added HTML for generating the preview (in index.js of card example). I have almost the same code to generate the output on the website (card.php of card example).

If I want to change the way this component is generated, I have to alter the HTML in two places.
Is this the advised way of solving this, or is there another way. So I don’t repeat the HTML in two places?

Thanks a lot!
René

Only if you generate the html on the server and your endpoint just returns it.