Is it possible to include the entry position (Structure) via the Entry Type Title Format?

This is the current format:

published in {postDate|date('F')} {postDate|date('Y')}

which renders: published-in-april-2018

This is what we need it to render:


I could create an actual Number field called “numberTitle”, attach it to the Entry Type, and set the Entry Type’s title to be dynamically generated using the template “{numberTitle}”, but why does this need to be done manually? You would think that the entries in a Section have a natural order in sequence or maybe they don't?

If the EntryVersion Model cannot deliver could Twig offer a solution?

  • Craft 2 or 3? And do you have multiple levels in your structure, or just one? Apr 8, 2018 at 12:25
  • Craft 3, single levels. This is for archival purpose of monthly newsletters, which are numbered, rather than titled. It seemed logical to have Craft do the counting - but to show this in the control panel was the great unknown. Enfin, this will work as re-structuring won't change the sequence of the entry. Thank you! PS: depreciated function/elements updated....
    – Nutmeg
    Apr 8, 2018 at 21:19

2 Answers 2


If your structure only has one level, you can use a title format like this:

Number {{ craft.entries.order('lft desc').positionedBefore(object).total()+1 }} published in {postDate|date('F')} {postDate|date('Y')}

This works when you create new entries, they'll get their current position in the title.

The problem is that this number won't get updated if you sort the stucture, since you'd need to resave all entries affected by the move, to update their title and slug. You can do this by creating a custom plugin (or module, if you're using Craft 3), listen to the appropriate events (for instance Element.EVENT_AFTER_MOVE_IN_STRUCTURE in Craft 3), and resave all entries. This could be a quite resource intensive operation if you have a lot of entries.

You could also get the number in Twig with the same code:

{{ craft.entries({ order: 'lft desc', positionedBefore: entry }).total() + 1 }}

This number will always be the updated number in the position, since the query is executed at runtime, instead of when an entry is saved. If you want to show this number to the enduser, I'd recommend this approach.

If you want to show the number in the control panel, I'd recommend looking into the ability to add custom columns to Craft's element indexes instead of having it in the title.

Maybe if you provide more information on the use-case, we can provide even more insight into possible solutions.


You can include the level

number {level} published in {postDate|date('F')} {postDate|date('Y')}
  • Thank you Robin, but that will give me "1". I am looking for the number in a sequence. Entry 1, entry 2, entry 3, etc..
    – Nutmeg
    Apr 6, 2018 at 8:22

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.