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.236

Latest news

  • ProcessWire Weekly #548
    In the 548th issue of ProcessWire Weekly we're going to check out a couple of new third party modules, introduce the latest ProcessWire core updates, and more. Read on!
    Weekly.pw / 9 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“I am currently managing a ProcessWire site with 2 million+ pages. It’s admirably fast, and much, much faster than any other CMS we tested.” —Nickie, Web developer