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 #555
    In the 555th issue of ProcessWire Weekly we're going to check out the latest core updates, introduce a new third party module that adds the ability to automatically convert email messages to pages, and more. Read on!
    Weekly.pw / 28 December 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

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH