teppo Posted June 1, 2018 Share Posted June 1, 2018 Fieldtype Page IDs is a third party Fieldtype that, simply put, stores Page references as integers (Page IDs). This fieldtype was built as a quick and dirty workaround for Page Reference fields' inability handle self-references due to circular reference issues. A project I've been working on for a while now includes a combination of RepeaterMatrix content blocks and tagging/categorization system that would've resulted in a lot of duplicate pages (and plenty of unnecessary manual work for content editors) had I used built-in Page Reference fields, and thus a new Fieldtype felt like the most sensible approach. Fieldtype Page IDs was designed to be loosely compatible with Page References in order to make conversions between the two feasible, but it is quite limited feature wise: largely due to the fact that stored values are actually just integers with no connection to Pages whatsoever some advanced selectors and related features are not supported, and page values can't be directly accessed configuration settings are limited to the bare essentials (selector string and Inputfield class) only a handful of Inputfields (AsmSelect, Checkboxes, Text) are (currently) supported Anyway, in case you need to store Page IDs (and Page IDs only) and are happy with the limitations mentioned above, feel free to give this Fieldtype a try. It has been working fine for me in one particular project, but hasn't been tested that much, so please tread carefully – and let me know if you run into any issues. GitHub repository: https://github.com/teppokoivula/FieldtypePageIDs Modules directory: https://modules.processwire.com/modules/fieldtype-page-ids/ 15 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted June 5, 2018 Share Posted June 5, 2018 Awesome!!!, just what I need today! Link to comment Share on other sites More sharing options...
gregg Posted May 17, 2019 Share Posted May 17, 2019 The FieldtypePageIDs module is exactly what i was looking for, wanting to see the unique page id in Admin. But i made a big error in setting the module's selector string: $page->id This produces a long error message starting with: Unknown selector operator: '$' ... Opening the field (to delete it) in Admin produces: Process returns no content So i tried to delete the field via API: $fields->delete('thefield'); Which produces another error long error message beginning with: Uncaught TypeError: Argument 1 passed to ProcessWire\Fields::___delete() must implement interface ProcessWire\Saveable, ... It seems that hooks are involved, which i don't understand hooks at all, so thought it best to ask for help on how to delete that field. Thank you. Link to comment Share on other sites More sharing options...
teppo Posted May 19, 2019 Author Share Posted May 19, 2019 Hey @gregg! If possible, please try updating the module to the latest version (0.12.0). This should resolve your issue. For the record, Fields::delete() expects an object implementing the Saveable interface as its first argument – so the correct syntax would be something along the lines of $fields->delete($fields->get('thefield')). Since you cannot use this method to delete a field that has been added to one or more fieldgroups (via templates), that might still fail though ? 2 Link to comment Share on other sites More sharing options...
gregg Posted May 24, 2019 Share Posted May 24, 2019 Hi Teppo, I would've replied sooner but i was away for a few days. Thanks for the module update and the corrected delete(), which worked perfectly. I'm still missing something, perhaps this is a question for the general forum: Is there a way to auto-populate a page's custom field with the Processwire page ID? Or even better, have 'id' appear as a field in admin, similar to 'title'. 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