Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

same autoid on duplicate a structure-item #70

Open
bnomei opened this issue Nov 3, 2021 · 3 comments
Open

same autoid on duplicate a structure-item #70

bnomei opened this issue Nov 3, 2021 · 3 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed wontfix This will not be worked on

Comments

@bnomei
Copy link
Owner

bnomei commented Nov 3, 2021

Hi @bnomei,
i am using your autoid-plugin 2.7.7 in a structure-field within site.yml in K3.5. Thank you for that!
Unfortunately i also have an issue with the same autoid on duplicate a structure-item. The autoid is the same 馃槮
Because i query/fetch that structure in a select-field by its autoid-value, i am not able to duplicate, otherwise the list is wrong.
Any idea how to fix that?
Thx, Dennis

@bnomei bnomei added the bug Something isn't working label Nov 3, 2021
@bnomei bnomei self-assigned this Nov 3, 2021
@bnomei
Copy link
Owner Author

bnomei commented Nov 3, 2021

hi dennis,

please post the blueprints for the site.yml and the page where you use that structure.

do you duplicate a structure item on the site object?

@dennisbaum
Copy link

dennisbaum commented Nov 4, 2021

Hi Bruno, thank you for getting into that issue!

site.yml

teasers:
  label: Global Teaser
  type: structure
  translate: false
  fields:
    autoid:
      type: hidden
      translate: false
    name:
      label: Name
      type: text
      required: true
    teaserh2:
      label: Headline
      type: text
      required: true
    ...

after duplicate a teaser in the panel, i get the same autoid in
site.txt

Teasers:

- 
  autoid: a6ba57nd
  name: About
  teaserh2: > Lorem Ipsum
  ...
- 
  autoid: onkrq6sb
  name: FAQ
  teaserh2: Noch Fragen?
  ...
- 
  autoid: onkrq6sb
  name: FAQ
  teaserh2: Noch Fragen?
  ...

which results in having only two teasers in the following selct-field by
page-xy.yml

type: group
fields:
  teaserheadline:
    label: Teaser
    type: headline
  teaserID:
    label:
      de: Teaser ausw盲hlen
      en: Select Teaser
    type: select
    required: true
    options: query
    query:
      fetch: site.teasers.toStructure
      text: "{{ structureItem.name }}"
      value: "{{ structureItem.autoid }}"

@bnomei
Copy link
Owner Author

bnomei commented Nov 4, 2021

ah using the structure duplicate option from the panel dropdown. that was introducted jun 2020 in k3.4. somehow i missed that feature being added.
https://github.com/getkirby/kirby/releases/tag/3.4.0

problem is i dont have any good idea how to solve that issue. there is no hook or any other event that i could do on php side. just making sure that if autoid finds two similar to change that later does seem to be a bit hackish to me. it still would have to do that on every save. but you could do that for you specific case.

what you could do to fix it for you setup is to create a page.updated:after hook. if it finds a duplicate id it grabs a new one from autoid (by calling $newid = autoid();) and set that. currently i dont have the time to create that code for you. if you get it working i would appreceate if you posted it here for reference. thanks.

@bnomei bnomei added help wanted Extra attention is needed wontfix This will not be worked on labels Nov 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants