Search the Community
Showing results for tags 'pagename'.
-
Hey Procis, wrote this - and my very first - hook „Prepend date in page name“, yesterday. Once you get it, this system and the API is magnificent. Thank you @ryan and @all contributers! On new (news) pages it works great so far. E.g.: Title: Testnews mit Ümläüten Altered page name: 2024-09-24-testnews-mit-ümläüten But on existing pages special characters are removed. E.g. Title: Partnerschaftliche Unterstützung - Ihr werdet gesucht! Altered page name: 2023-07-27-fans1991-partnerschaftliche-untersttzung-ihr-werdet-gesucht Another example is attached. There you can see, that the ProcessPageEdit-message shows the right path!? I have this in my site/config.php to allow only german special characters: $config->pageNameCharset = 'UTF8'; $config->pageNameWhitelist = '-_abcdefghijklmnopqrstuvwxyz0123456789äöüß'; Temporary uninstalled Module „PagePathHistory“ with no look. The code of my hook (suggestions for improvement are very welcome!): /* NEWS pages only: prepend date in page-name */ $wire->addHookAfter('Pages::saveReady', function($event) { // get current Page object — in this case this is the first argument for the $event object $page = $event->arguments(0); // Only for pages with news template if($page->template == 'news') { // Test if field day exists, otherwise exit if (!$page->template->hasField('day')) { $event->message("Field 'day' is missing!"); return; } $title = $page->get('title'); // Sanitize title and substitute special characters $optimizedTitle = wire('sanitizer')->pageNameUTF8($title); //$optimizedTitle = wire('sanitizer')->pageName($title, Sanitizer::okUTF8); // or translate option $date = wireDate('Y-m-d', $page->day); // Set output formatting state off, for page manipulation $page->of(false); $page->name = $date.'-'.$optimizedTitle; //$page->save('name'); $event->message("New saved name is $page->name"); //$event->message("Path of new saved page is $page->path"); } }); Any idea why this doesn't works on all existing news, too? Thx and 👋 Sebastian
-
Hi, i have a template with allowed urlSegments. No other restrictions in the template. My test template is simple. Just trying to get and echo the url segment. But the problem is, if I use _ (or - or .) together with uppercase characters, my template file is never processed. The 404 redirect happens before. this works: /url/aa_aa (or /url/aa-aa) but these fail, also with - and . /url/Aa_aa /url/aA_aa /url/aa_Aa /url/aa_aA So it doesn't matter where the uppercase character is. <?php namespace ProcessWire; if($input->urlSegment1) { echo $input->urlSegment1 } Processwire version 3.0.210 with Php 8.2 $config->maxUrlSegments = 8; $config->pageNameCharset = 'UTF8'; $config->pageNameWhitelist = '-_.abcdefghijklmnopqrstuvwxyz0123456789æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź-FISEN'; My site is multilingual and this might have something to do with that. In my 404 logs i get something like this: 2023-03-03 12:35:19 41 /url/aa-aA page doesn't exist [IP: 127.xxx.xxx.xxx] [UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36] 2023-03-03 12:35:24 41 /fi/url/aa-aA page doesn't exist [IP: 127.xxx.xxx.xxx] [UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36] Any help appreciated. We actually have this bug in production at the moment...
- 6 replies
-
- urlsegments
- url issue
-
(and 1 more)
Tagged with:
-
I'm trying to create a pagename (for internal use, not for presentation to the users) with multiple dashes in the middle. Here's an excerpt of my code: $p = new Page(); $p->template = 'template-name'; $p->name = "$prod--$variation"; ProcessWire seems to apply $sanitizer->pageName($name, true) which converts multiple dashes to a single dash so the page name doesn't have "--" in it. How can I force it to have multiple dashes?