regesh Posted May 25, 2015 Share Posted May 25, 2015 here is a situation! i want to store records for actions (date,from,to,manager) as children pages to page "actions". And i don't need the title. it would be grate to set the default value for "title" as page_id for template "action". So it means when i create new page with template "action" field "title" is already fild with number 1111 (for example). Or if title won't be filled it wil be saved with as page_id. Thanks for advise! Link to comment Share on other sites More sharing options...
SiNNuT Posted May 25, 2015 Share Posted May 25, 2015 Just a quick response. I'm not aware of any 'out-of-the-box' solutions but it would be easy enough to come up with a small module for this. There are some threads about this on the forum, with code that you can almost use as-is or adjust to your needs: https://processwire.com/talk/topic/4201-how-to-automatically-set-the-value-of-a-field/ https://processwire.com/talk/topic/2331-doing-additional-logic-after-saving-a-new-page/ Maybe others will have other suggestions. Link to comment Share on other sites More sharing options...
regesh Posted May 25, 2015 Author Share Posted May 25, 2015 Thanks! That's what i need. But it would be gread to be able to select for what page templates it will be applied. Thanks again! Link to comment Share on other sites More sharing options...
bernhard Posted May 25, 2015 Share Posted May 25, 2015 you can also use the 1-step adding of pages if all of the children have the same template: https://processwire.com/blog/posts/processwire-2.5-changelog/#adding-pages then you can set the title-field to hidden on the template-settings. or am i misunderstanding you? 1 Link to comment Share on other sites More sharing options...
regesh Posted May 25, 2015 Author Share Posted May 25, 2015 even if hidden it must be filled. I told about to auto filled for custom pages Link to comment Share on other sites More sharing options...
bernhard Posted May 25, 2015 Share Posted May 25, 2015 yes that's definitely possible with what i said. setup 1-step adding of pages. set template to "action" and default title to eg date(...) or leave it as it is and all newly created children will have their title populated automatically. if you hide that field the client will not see anything of this "magic" but maybe your "for custom pages" is too much for this method... anyway: as sinnut said a simple module would do that easily! just wanted to make sure you know about the 1-step thing before you create a module that does the same Link to comment Share on other sites More sharing options...
SiNNuT Posted May 25, 2015 Share Posted May 25, 2015 Thanks! That's what i need. But it would be gread to be able to select for what page templates it will be applied. Thanks again! You mean via a backend module interface instead of doing it in the module code? You could make a configurable module. See https://github.com/ryancramerdesign/Helloworld for an up to date example. Link to comment Share on other sites More sharing options...
regesh Posted May 26, 2015 Author Share Posted May 26, 2015 Module is better choice in my way because i won't add pages in one step. And i have another question!) I want to add new field "checkbox" to template and i need it be checked everywhere. Another variant is to change all pages i need using "foreach" but i can't find how to to change field value in api if i have only page id where it field is used. Link to comment Share on other sites More sharing options...
Can Posted May 30, 2015 Share Posted May 30, 2015 Another variant is to change all pages i need using "foreach" but i can't find how to to change field value in api if i have only page id where it field is used. If I got you right you want to check all checkboxes via API? What do you mean with "only page id where the field is used"? You could have a selector like foreach($pages->find("field_to_check=") as $p) { $p->of(false); $p->field_to_check = 1; $p->save("field_to_check"); } Maybe it was field_to_check=0 for unchecked checkboxes?! Or am I getting you wrong? 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