KarlvonKarton Posted September 29, 2017 Posted September 29, 2017 Hello there, When I add a user and compare that with pageName, then I can see a difference with given $uniqueName. $uniqueName= 'Prospère Jouplaboum'; $u = $users->add($uniqueName); // Results in name: prospe-ere-jouplaboum /* VS. */ $username = $sanitizer->pageName(uniqueName); // Results in name: prospre-jouplaboum ps: to correct the issue, I had to: /* First pageName then add user... */ $uniqueName = $sanitizer->pageName($uniqueName); $u = $users->add($uniqueName); Strange, no?
abdus Posted September 29, 2017 Posted September 29, 2017 PagesEditor class uses $sanitizer->pageName() a bit differently. // Users.php add() -> PagesType::add() // PagesType.php public function ___add($name) { // ... $page->parent = $parent; $page->name = $name; // ... try { $this->save($page); } // ... } // PagesEditor.php protected function savePageQuery(Page $page, array $options) { // ... if(strpos($page->name, $this->untitledPageName) === 0) $this->pages->setupPageName($page); $data = array( 'parent_id' => (int) $page->parent_id, 'templates_id' => (int) $page->template->id, 'name' => $this->wire('sanitizer')->pageName($page->name, Sanitizer::toAscii), // ... ); // ... } 1
KarlvonKarton Posted September 29, 2017 Author Posted September 29, 2017 Then how can I check if user 'Prospère Jouplaboum' exists (when I search by his pageName)?
abdus Posted September 29, 2017 Posted September 29, 2017 $sane = $sanitizer->pageName('Prospère Jouplaboum', Sanitizer::toAscii); $exists = $pages->count("name=$sane") > 0; 5
Robin S Posted September 30, 2017 Posted September 30, 2017 17 hours ago, KarlvonKarton said: $uniqueName= 'Prospère Jouplaboum'; $u = $users->add($uniqueName); // Results in name: prospe-ere-jouplaboum /* VS. */ $username = $sanitizer->pageName(uniqueName); // Results in name: prospre-jouplaboum Hmmm, neither of those is a very good transliteration. $sanitizer->pageNameTranslate() gives the better result of prospere-jouplaboum, which is also the same result you get if you paste the name when adding a user via the PW admin. Seems like the core should be using that in PagesEditor instead of the Sanitizer::toAscii option. 3
KarlvonKarton Posted September 30, 2017 Author Posted September 30, 2017 In the meanwhile I've tested the pageName with option Sanitizer::toAscii, but that still results in the same differences. So I'm sticking to this for now: // adding $saniName = $sanitizer->pageNameTranslate('Prospère Jouplaboum'); $u = $users->add($saniName); // checking $sane = $sanitizer->pageNameTranslate('Prospère Jouplaboum'); $exists = $pages->count("name=$sane") > 0; 1
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