1

I have a channel where I need each entry's Title include a sequential number, like this: 10003 - Entry Title

Is there a way to prepend a sequential number to the entry title?

1 Answer 1

1

I think you'll need to implement this with the Elements::EVENT_AFTER_SAVE_ELEMENT event and keep a record of the number.

If it doesn't need to be sequential 1,2,3 you could use a dynamic title and use {{object.sourceId}} which would be the entry id which will always increment

1
  • Yeah, this. I wondered about using something like {craft.entries.section('pages')|length} in the Title Format field, but that would update the number to the total length every time you updated the entry. You may still run into problems with the user being able to change the number when they edit the page. Commented Jun 22, 2020 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.