Shared structure field in Panel

In the panel, is there a way to share a structure field of a parent page across the children pages?

My use case: I would like to separate a text into subpages (chapters), but have a structure field containing all the footnotes. This structure field would sit in the parent page, but ideally it would appear on all children pages, so i can set the footnotes in the text manually.

We already have it appearing via a select query or a radio query, but here i can’t get the numbering of the structure field, because it starts with a 0 and not a 1. I couldn’t find a way to use query language to add 1 to the indexOf there…

Any ideas are very much appreciated.

It’s not possible to share a field across multiple pages, unless you keep the parent page in sync with the subpages and vice versa (i.e. via a hook), but that wouldn’t be sharing but duplicating stuff.

Unfortunately, it also doesn’t seem to work sufficiently with a “passive” field, for example a radio field querying the structure field. This way at least i get all the footnotes from the parent page, but in the wrong numbering (starting with 0).
One way would be to create my own field (extension of the radio field, with correct numbering and no selection), but this extends my abilities…

What is the purpose of having the footnotes there? As a reference for editors who should input the right numbers?

Yes, indeed, it is just merely a reference to set the correct numbers in the text.

Then why not create a page method or model that outputs the references in the right way as a list and put that into an info field.

I have never worked with a page model before and was assuming, that this was for the frontend only. Do you know of an example where the page model was used for a panel page? I think this might exceed my abilities at this point… :frowning:

Using a model is optional, you might just as well use a function, but if you only need it for this particular page type, a model makes the most sense.

Such a model function can then be used in the panel just like any other method in query language.

Example:

// Should be the model name of the child page
class SomePage extends Page
{
    public function footnotes() {
        $footnotes = $this->parent()->footnotes()->toStructure();
        $html      = '<ol>';
        foreach( $footnotes as $footnote ) {
            $html .= '<li>' . $footnote->text() . '</li>';
        }
        $html .= '</ol>';

      return $html;
      
    }
}

In blueprint

    fields:
      info:
        type: info
        text: |
          {{ page.footnotes }}

Crazy. This worked! Thanks a lot!!!