Skip to content

Kirby 3.9.8

$page->changeSlug()

Changes the slug/uid of the page

$page->changeSlug(string $slug, ?string $languageCode = null): Kirby\Cms\Page

Parameters

Name Type Default
$slug * string
$languageCode string|null null

Return type

Kirby\Cms\Page

This method does not modify the existing $page object but returns a new object with the changes applied. Learn more →

Exceptions

Type Description
Kirby\Exception\LogicException If the directory cannot be moved

Parent class

Kirby\Cms\Page

Details

Kirby's objects are immutable. That means, when you modify an object like $page, $file etc. using a method like update(), changeTitle() and so on, a new object is returned. Therefore, you have to store the returned object in a new variable to be able to further work with it.