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 #518
    The 518th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 13 April 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani