I have a structure type field in my projects panel. (Refer to the screenshot below)
I was wondering if its possible to auto-number the rows ascendingly each time i add / remove / re-order them.
Why do you need the index at all if it is supposed to change?
Edit: Maybe you could use the snippet field instead of the structure field, then make the index a readonly field that only displays a number via a snippet without actually storing anything (just an idea, haven’t tested this).
thanks for the reply. im currently trying out the snippet field plugin.
I’ve managed to link a custom snippet to the index field and display the same thing.
but i have no idea what i should do to incrementally increase the value in the snippet. hmm
I thought it would be possible to get the index of the item in the structure field, but for this to work, there would have to be some unique value to find the correct item within the structure.
And it seems the snippet is only shown if the field contains a value, not if it is empty. Another downside is that the value is only displayed after saving…
You can always use a hook that renumbers your index when a page is saved, but that then only happens on save as well.