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

Allow modification of content in prePublish hook #7133

Open
drzax opened this issue Mar 7, 2024 · 0 comments
Open

Allow modification of content in prePublish hook #7133

drzax opened this issue Mar 7, 2024 · 0 comments
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@drzax
Copy link

drzax commented Mar 7, 2024

Is your feature request related to a problem? Please describe.
I want the CMS to automatically set the published date for entries when an entry is published for the first time. This should be doable with the prePublish hook a handler something like:

CMS.registerEventListener({
        name: "prePublish",
        handler: ({entry}) => {
          const now = new Date().toISOString();
          let data = entry.get('data');
          if (data.get('status') === 'draft') {
            data = data.set('published', now);
          }
          return data.set('status', 'published');
        }
      });

But the invokePrePublishEvent function (unlike invokePreSaveEvent) doesn't return the updated data.

Describe the solution you'd like
I'd like the prePublish hook to allow updating entry data.

Describe alternatives you've considered
I tried to think of a way to do this only using the preSave hook, but don't think it's possible.

Additional context
It would be worth considering whether all hooks (or at least all pre-hooks should be able to update data.

@drzax drzax added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

1 participant