PagesNames::uniquePageName() method

Get a unique page name

  1. If given no arguments, it returns a random globally unique page name.
  2. If given just a $name, it returns that name (if globally unique), or an incremented version of it that is globally unique.
  3. If given both $page and $name, it returns given name if unique in parent, or incremented version that is.
  4. If given just a $page, the name is pulled from $page and behavior is the same as #3 above.

The returned value is not yet assigned to the given $page, so if it is something different than what is already on $page, you’ll want to assign it manually after this.

Usage

// basic usage
$string = $pagesNames->uniquePageName();

// usage with all arguments
$string = $pagesNames->uniquePageName($name = '', $page = null, array $options = []);

Arguments

NameType(s)Description
name (optional)string, Page, array

Name to make unique You may optionally substitute the $page argument or $options arguments here, if that is all you need.

page (optional)
options (optional)array
  • parent (Page|null): Optionally specify a different parent if $page does not currently have the parent you want to use.
  • language (Language|int): Get unique for this language (if multi-language page names active).
  • page (Page|null): If you specified no $page argument, you can optionally bundle it in the $options array.
  • name (string): If you specified no $name argument, you can optionally bundle it in the $options array.

Return value

string

Returns unique name


PagesNames methods and properties

API reference based on ProcessWire core version 3.0.244

Latest news

  • ProcessWire Weekly #559
    The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 25 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull