regesh Posted July 19, 2016 Share Posted July 19, 2016 how to make that every new page created has title the same as pageid. Link to comment Share on other sites More sharing options...
DaveP Posted July 19, 2016 Share Posted July 19, 2016 This works for me. <?php $p = new Page(); $p->template = 'mytemplate'; $p->parent = $pages->get('/parent/'); $p->title = 'temp'; $p->save(); // $p now has an id $p->title = $p->id; // possibly with a prefix or suffix $p->save(); The important bit is to save the page so that PW can assign it an id. Link to comment Share on other sites More sharing options...
regesh Posted July 19, 2016 Author Share Posted July 19, 2016 thanks but this is not what i mean. it's better to be done with hook, so i won't need to give title even using api. Link to comment Share on other sites More sharing options...
szabesz Posted July 19, 2016 Share Posted July 19, 2016 (edited) @regesh How about using Pages::saved ? http://processwire.com/api/hooks/#before_or_after an example of using the hook: Edited July 19, 2016 by szabesz Pages::saved instead of Pages::save 1 Link to comment Share on other sites More sharing options...
adrian Posted July 19, 2016 Share Posted July 19, 2016 You could also make use of this module: http://modules.processwire.com/modules/process-redirect-ids/ 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