ProcessWire - URL Segments: Unterschied zwischen den Versionen
Aus Wikizone
(Die Seite wurde neu angelegt: „URL Segemente kann man in PW ähnlich auswerten wie GET Parameter https://processwire.com/docs/front-end/how-to-use-url-segments/#best-practices Beispiel <sy…“) |
|||
| Zeile 25: | Zeile 25: | ||
throw new Wire404Exception(); | throw new Wire404Exception(); | ||
} | } | ||
| + | |||
| + | == Sanitzier für URL-Segmente? == | ||
| + | Eventuell dieser: | ||
| + | $sanitizer->pageName($input->urlSegment1, true); // URL segments are already sanitized as page names but not to lowercase | ||
| + | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Aktuelle Version vom 31. März 2021, 08:06 Uhr
URL Segemente kann man in PW ähnlich auswerten wie GET Parameter
https://processwire.com/docs/front-end/how-to-use-url-segments/#best-practices
Beispiel
// we are only using 1 URL segment, so send a 404 if there's more than 1
if(strlen($input->urlSegment2)) throw new Wire404Exception();
switch($input->urlSegment1) {
case '':
// Segment 1 is empty so display main content
break;
case 'photos':
// Display photo gallery
break;
case 'map':
// Display map
break;
default:
// Anything else? Throw a 404
throw new Wire404Exception();
}
== Sanitzier für URL-Segmente? ==
Eventuell dieser:
$sanitizer->pageName($input->urlSegment1, true); // URL segments are already sanitized as page names but not to lowercase