Jump to content

Get page index based on the order in the admin backend


greg-ms
 Share

Recommended Posts

Is it possible to get the index/item key of a page, based on the order I've inserted them in the admin backend?

e.g. there are a couple of Pages, 1-100, in the backend and I need a number which I can render, so the user can see which is the oldest and newest page.

There's the getItemKey Method, but it delivers the index values from the current page list result: if I change to another page (pagination)  the item key depends always on the current result list (so it's always zero-based).

Link to comment
Share on other sites

so the user can see which is the oldest and newest

I take it you don’t want to show the date the page was created? That would be $page->created.

$page->sort gives you the zero-based sort index, but it’s only unique in relation to the parent. This might be the closest to your requirement.

$page->id is not necessarily consecutive and starts at 1000, but it’s unique site wide. I believe ProcessWire doesn’t reuse deleted IDs, so they should reflect the order of page creation. However, every new admin page and repeater item will increase this number. Do with that what you will.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...