Blueprint Query displaying full path on page instead of just title

Hi - thanks for any help on this.
I have a query set up in my blueprint file to retrieve a list of names (titles of entries) in a select field.
All works fine - the dropdown is populated with the list of titles.

Blueprint:

artist:
label: Artist
type: select
options: query
query: site.find(‘artists’).children.listed

However when I use the following code in the template…

Artist: <?= $page->artist() ?>

The displayed result is the following:

Artist: artists/mark-rothko

which is the full path - with a hyphen in the title

What I want to do is just retrieve and display the title (without the hyphen) or

If I create two fields in the artist blueprint -‘firstname’ and ‘lastname’ - could I retrieve and display those instead? If so, could you help with the correct query/code??

Thank you!

Your select field apparently stores the ID of the pages from the query (that is the artists/mark-rothko).

You could modify the select field in your blueprint to store the page title rather than the ID:

artist:
  label: Artist
  type: select
  options: query
  query:
    fetch: find('artists').children.listed
    text: "{{ arrayItem.title }}"
    value: "{{ arrayItem.title }}"

Alternatively, <?= page( $page->artist() )->title() ?> in your template should do the trick for the current blueprint (using the retrieved page ID with the page() helper).

I am sorry but three minutes wasn’t fast enough. Thank you so much! Works either way!

Since the title is probably changed more often than the page id, storing the id to me seems to be the better option. If you allow changing the slug, consider using the AutoID plugin and store that value instead.

Many thanks indeed - I will check out the plugin also.