Clarity Posted September 14, 2021 Share Posted September 14, 2021 Hello everyone! I have a cyrillic string transliteration of which I want to use as a name for the new page via cloning another page with a custom title. I'm using this function: function foo($copyFromPage, $parent, $newTitle, $language) { $copyFromPage->of(false); $clone = wire('pages')->clone($copyFromPage); $clone->of(false); $clone->title->setLanguageValue(wire('languages')->get($language), $newTitle); $clone->name = $newTitle; $clone->parent = $parent; wire('pages')->save($clone, ['ignoreFamily' => true]); } Usage of my function is like: foo(65536, 32768, 'Новая страница', 'ru'); I need to translate 'Новая страница' into a name like novaya-stranitsa in order to have a page to be named correctly (now I have hyphen instead of name). Could you please tell me how to do it in ProcessWire? Link to comment Share on other sites More sharing options...
virtualgadjo Posted September 14, 2021 Share Posted September 14, 2021 Hi, i don't know if it's what you are looking for but in pw, you have a setting tab for each page where you can set whatever name you want, even completely different from the page title a little trick that may help, when creating a page pw auto fill the name field based on the title you choose, what i do when i want them different, i first fill the name and the title afterwards ? have a nice day 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted September 14, 2021 Share Posted September 14, 2021 You must be looking for $sanitizer->pageName() (probably, with beautify parameter set to Sanitizer::translate). 3 Link to comment Share on other sites More sharing options...
Clarity Posted September 15, 2021 Author Share Posted September 15, 2021 Thank you! It works. 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