How to use UUID in structure entry?

Hey!

Thank you very much for your great cms! I really love the new unique id system in Kirby 3.8. Before this feature I used the the AutoID-plugin by bnomei. AutoID also works in structure fields. The new native feature also seems to be integrated in structures:

The Uuid classes provide an interface to connect identifiable models (page, file, site, user, blocks, structure entries) with a dedicated UUID string.

But I’m not sure how to use the UUID in the structure field.

districts:
	label: 
		en: Districts
		de: Bezirke
	type: structure
	fields:
		name:
			label: 
				en: Name
				de: Name
			type: text
	width: 1/4
	sortBy: name DESC
parks:
	label: Parks
	type: structure
	fields:
		name:
			label: 
				en: Name
				de: Name
			type: text
		district:
			label: 
				en: District
				de: Bezirk
			type: select
			options:
				type: query
				query: site.districts.toStructure
				text: "{{ structureItem.name }}"
				value: "{{ structureItem.uuid }}"

But I can’t find any uuid in the site.txt-file, where is the structure stored:

----

Districts:

- 
  name: Charlottenburg-Wilmersdorf
- 
  name: Friedrichshain-Kreuzberg
- 
  name: Lichtenberg
- 
  name: Marzahn-Hellersdorf
- 
  name: Mitte
- 
  name: Neukölln
- 
  name: Pankow
- 
  name: Reinickendorf
- 
  name: Spandau
- 
  name: Steglitz-Zehlendorf
- 
  name: Tempelhof-Schöneberg
- 
  name: Treptow-Köpenick

----

Because of the uuid in the query the editor fails and lists only one structure entry:

What am I doing wrong? And if the UUID is not supported in structures yet: What alternative do I have? The AutoID is already end-of-life. :neutral_face:

Thanks!

That’s exactly the case. UUIDs for the structure field will come in a later release.

Hm, good question. One way would be to add UUIDs using a hook in saving.

1 Like

Thanks for your quick reply! :grinning:

Hm, to code a plugin to add UUIDs via hooks sounds quite ambitious… Do you have an ETA for the UUIDs for the structure field?

No, I can’t tell. We would like to implement it as soon as possible, but UUIDs for structure fields are a bit tricky and need careful planning, that’s why they haven’t made it into 3.8.0 yet.

Looks like you can still use the AutoID plugin. Here’s a quote from Bruno:

  1. only the very latest autoid release is blocking k3.8 and that is ONLY if you use composer to install it. if you hardwire plugin v2.8.1 or download the zip you can keep using that even with k3.8 i decided create 2.8.2 with blocking k3.8 to emphasize that uuids are core now. (edited)
2 Likes