Blueprint: select uid children pages

Hello,

how can I add a select field into the my blueprint
to select the uid of a children page from the current page ?

 submenu-target:
    label: Submenu target
    type: select 
    options: query
    query:
      page: 
      value: '{{uid}}'

From the docs:

Any page URI. This is a powerful way to fetch any kind of data from any other page. You can even use relative paths to step up levels in the hirarchy. For example: …/…/ to go two levels up or / to get to the top level.

This means you should be able to just put the id of the page without any ‘/’ before

Does this not work for you?

 submenu-target:
    label: Submenu target
    type: select 
    options: children

Also, you shouldn’t use hyphens in field names. Use underscores or camelCase instead, see docs here https://getkirby.com/docs/panel/blueprints/form-fields#field-names

 submenu_target:
    label: Submenu target
    type: select 
    options: children

or

 submenuTarget:
    label: Submenu target
    type: select 
    options: children

If you want to use the query option, it should lool like this:

options: query
query:
  fetch: children
  value: '{{uid}}'

The uid is default for value anyway, so you may omit that.

If you are not using anything else than default options, you might as well use the short form as proposed by @jevets

thanks @all for the super fast answers

Navigation
if the mother have child and have no content you have the choice
which child is linked with the mother.

 if($item->submenu_target() != '')
              {
              	echo  $item->url().'/'.$item->submenu_target();
              }
              else
              {
              	echo $item->children()->first()->url();}
              }
1 Like