Pages Names

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 $var?     Show args?       Only hookable?    

Manipulators

NameReturnSummary 
$pages->names->adjustNameLength(string $name)
string

If name exceeds maxLength, truncate it, while keeping any numbered suffixes in place

 
$pages->names->checkNameConflicts(Page $page)
None

Check given page’s name for conflicts and increment as needed while also triggering a warning notice

 
$pages->names->incrementName(string $name)
string

Increment the suffix of a page name, or add one if not present

 
$pages->names->setupNewPageName(Page $page)
string

Assign a name to given Page (if it doesn’t already have one)

 

Informational

NameReturnSummary 
$pages->names->defaultPageNameFormat(Page $page)
string

Get the name format string that should be used for given $page if no name was assigned

 
$pages->names->hasAdjustedName(Page $page)
bool

Does the given page have a modified “name” during this request?

 
$pages->names->hasAutogenName(Page $page)
string bool

Does the given page have an auto-generated name (during this request)?

 
$pages->names->hasNumberSuffix($name)
int bool string

Does the given name or Page have a number suffix? Returns the number if yes, or false if not

 
$pages->names->isUntitledPageName(string $name)
bool

Does the given page have an untitled page name?

 
$pages->names->nameAndNumber(string $name)
array

If given name has a numbered suffix, return array with name (excluding suffix) and the numbered suffix

 
$pages->names->pageNameExists(string $name)
int

Is the given name is use by a page?

 
$pages->names->pageNameHasConflict(Page $page)
string bool

Does given page have a name that has a conflict/collision?

 
$pages->names->untitledPageName()
string

Return 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.252