tires Posted Monday at 11:24 AM Share Posted Monday at 11:24 AM Is there a way to automatically create the title and the name of a page from the content of two fields? I have the problem that the editor usually has to enter the same thing in the title field as in these two fields. What is the easiest way? Or is there perhaps a module? Link to comment Share on other sites More sharing options...
taotoo Posted Monday at 01:52 PM Share Posted Monday at 01:52 PM You can use FieldtypeConcat, or do it with a hook. https://processwire.com/modules/fieldtype-concat/ // Merge First and Surname for Title and Name if($page->template == 'some-template') { // Don't change name field if page is going to trash if(!$page->isTrash) { // If the fields that make up the title are populated if($page->first_name && $page->surname) { // Set the title $page->title = "{$page->first_name} {$page->surname}"; // Sanitize the title as a page name $name = $event->wire()->sanitizer->pageName($page->title, true); // Set the page name while making sure it auto-increments if there is a sibling page with the same title $page->name = $pages->names()->uniquePageName($name, $page); } } } 2 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