Adding a custom field to a blueprint to add content from another page

Hi all, I am new to grav and I really love it. I want to create a custom blueprint for a page where I can add content from another page as custom field. As an example lets say I have two collection types, authors and books. I have a list of pages as books and list of pages as authors. What I want to do is add a custom field to the books blueprint add an author (content as an input field). Can anyone please help me to achieve this?

I’m not really sure if I understand you correctly…
Do you want a custom field for the books blueprint, so that you could add a new author, which then will generate a new page in the list of authors?
Or do you simply want to be able to select an existing author page with a dropdown on your book page?
If you could clarify a bit, I will try to help you achieve this :slight_smile:

Hi Thanks for your reply @benigartenmann! I want to achieve the latter; want to be able to select an existing author. But I wouldn’t mind learning both methods as it might be helpful in future projects :slight_smile:

Ok, I did something similar for my website and tried to apply it to your use case.
Your blueprint should look something like this (or with more fields depending on what you already have):

title: Book
    type: default
    context: blueprints://pages

            type: tabs
            active: 1

                            type: pages 
                            label: Author
                            show_all: true
                            show_modular: true

Than you can get the content of the author page in the template like this:

{% set author = page.find( %}
{{ author.content }}

I did not test it myself. If it does not work, I’m happy to dig deeper.
One note: With the blueprint set up like this, you do have all your pages in the dropdown, not only the authors… I didn’t find a property to filter the list of pages in the docs.

Honestly, I don’t know if the other method is possible without writing a custom field or even a plugin. As your use case should be fulfilled with the method above, I didn’t put in the time for researching this…
Maybe someone else on the forum knows the solution already?

This method won’t work as it shows all the pages. I had a write a custom plugin and called it using @data-options. It may not be the optimal solution though. Thanks for your help mate! :slight_smile: