PagesNames class

This class includes methods for generating and modifying page names.

While these methods are mosty for internal core use, some may at times be useful from the public API as well. You can access methods from this class via the Pages API variable at $pages->names().

if($pages->names()->pageNameExists('something')) {
  // A page named “something” exists
}

// generate a globally unique random page name
$name = $pages->names()->uniqueRandomPageName();

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the PagesNames class also inherits all the methods and properties of: Wire.

Show class?             Show args?        

Manipulators

NameReturnSummary 
PagesNames::adjustNameLength(string $name)
stringIf name exceeds maxLength, truncate it, while keeping any numbered suffixes in place 
PagesNames::checkNameConflicts(Page $page)
(nothing)Check given page’s name for conflicts and increment as needed while also triggering a warning notice 
PagesNames::incrementName(string $name)
stringIncrement the suffix of a page name, or add one if not present 
PagesNames::setupNewPageName(Page $page)
stringAssign a name to given Page (if it doesn’t already have one) 

Informational

NameReturnSummary 
PagesNames::defaultPageNameFormat(Page $page)
stringGet the name format string that should be used for given $page if no name was assigned 
PagesNames::hasAdjustedName(Page $page)
boolDoes the given page have a modified “name” during this request? 
PagesNames::hasAutogenName(Page $page)
string boolDoes the given page have an auto-generated name (during this request)? 
PagesNames::hasNumberSuffix($name)
int bool stringDoes the given name or Page have a number suffix? Returns the number if yes, or false if not 
PagesNames::isUntitledPageName(string $name)
boolDoes the given page have an untitled page name? 
PagesNames::nameAndNumber(string $name)
arrayIf given name has a numbered suffix, return array with name (excluding suffix) and the numbered suffix 
PagesNames::pageNameExists(string $name)
intIs the given name is use by a page? 
PagesNames::pageNameHasConflict(Page $page)
string boolDoes given page have a name that has a conflict/collision? 
PagesNames::untitledPageName()
stringReturn the untitled page name string 

Additional methods and properties

In addition to the methods and properties above, PagesNames also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #549
    In the 549th issue of ProcessWire Weekly we’re going to check out the latest core updates, highlight one older yet still very relevant third party module, and more. Read on!
    Weekly.pw / 17 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 just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer