Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to replace content items with an unknown ID using recipes #16070

Open
Piedone opened this issue May 16, 2024 · 4 comments
Open
Milestone

Comments

@Piedone
Copy link
Member

Piedone commented May 16, 2024

Is your feature request related to a problem? Please describe.

Copied from Lombiq/Helpful-Libraries#199 by @sarahelsaig.

Currently it's not possible to overwrite a content item with a recipe if its ContentItemId is unknown - for example if it was created from a recipe using "ContentItemId": "[js: uuid()]". We should include some recipe mechanism to get around this.

E.g. TestAddingMenuItemToBlogMainMenuAsync() in Lombiq Base Theme would benefit from this.

Describe the solution you'd like

  1. Add a IGlobalMethodProvider that let's you find the ContentItemId from alias, e.g.
    "ContentItemId": "[js: idFromAlias('main-menu')]".
  2. Create a new recipe step that removes a content item by query.

I'm not sure if either of these is possible during setup, if the alias index may not be populated yet?

Describe alternatives you've considered

Implementing the same thing in a custom module.

@MikeAlhayek
Copy link
Member

What about other scenarios like locating an item by a serial number or some other unique identifier? I have not gave this much of a thought, but what if we add a new LocatingAsync event on the content manager so that we can locate an item using other identifiers like alias, serial number, and anything else we have a handler for?

@Piedone
Copy link
Member Author

Piedone commented May 16, 2024

We could generalize it to use IContentHandleManager.GetContentItemIdAsync() behind the scenes, so any content handle would work. Along the lines of:

"ContentItemId": "[js: idFromHandle('alias:main-menu')]"

I.e., exactly what the Menu TagHelper does too.

@sebastienros
Copy link
Member

handle('alias:main-menu') (my preference)
find('alias:main-menu')
load('alias:main-menu')

@sebastienros sebastienros added this to the 2.x milestone May 16, 2024
@Piedone
Copy link
Member Author

Piedone commented May 16, 2024

Or anothernameforthesamethingwouldnthurt('alias:main-menu') :D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants