greg-ms Posted December 14, 2014 Share Posted December 14, 2014 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 More sharing options...
Jan Romero Posted December 14, 2014 Share Posted December 14, 2014 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. 3 Link to comment Share on other sites More sharing options...
greg-ms Posted December 14, 2014 Author Share Posted December 14, 2014 Perfect, $page->sort fits my need. Thank you very much! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now