Jump to content

No need in title


regesh
 Share

Recommended Posts

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

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

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

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

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

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...