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.
Manipulators
Name | Return | Summary | |
---|---|---|---|
$pages->names->adjustNameLength() $pages->names->adjustNameLength(string $name) $pages->names->adjustNameLength(string $name, int $maxLength = 0) | string | If name exceeds maxLength, truncate it, while keeping any numbered suffixes in place | |
$pages->names->checkNameConflicts() $pages->names->checkNameConflicts(Page $page) $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() $pages->names->incrementName(string $name) $pages->names->incrementName(string $name, $num = null) | string | Increment the suffix of a page name, or add one if not present | |
$pages->names->setupNewPageName() $pages->names->setupNewPageName(Page $page) $pages->names->setupNewPageName(Page $page, string $format = '') | string | Assign a name to given Page (if it doesn’t already have one) |
Informational
Generators
Name | Return | Summary | |
---|---|---|---|
$pages->names->pageNameFromFormat() $pages->names->pageNameFromFormat(Page $page) $pages->names->pageNameFromFormat(Page $page, $format = '', array $options = []) | string | Create a page name from the given format | |
$pages->names->uniquePageName() $pages->names->uniquePageName() $pages->names->uniquePageName($name = '', $page = null, array $options = []) | string | Get a unique page name | |
$pages->names->uniqueRandomPageName() $pages->names->uniqueRandomPageName() $pages->names->uniqueRandomPageName(array $options = []) | string | Get a random, globally unique page name |
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