Get a page by its path, similar to $pages->get('/path/to/page/') but with more options
Please note
- There are no exclusions for page status or access. If needed, you should validate access on any page returned from this method.
- In a multi-language environment, you must specify the $useLanguages option to be true, if you want a result for a $path that is (or might be) a multi-language path. Otherwise, multi-language paths will make this method return a NullPage (or 0 if getID option is true).
- Partial paths may also match, so long as the partial path is completely unique in the site. If you don't want that behavior, double check the path of the returned page.
- See also the newer/more capable
$pages->pathFinder()
methodsget('/path/')
andgetPage('/path/')
.
Usage
// basic usage
$page = $pagesLoader->getByPath(string $path);
// usage with all arguments
$page = $pagesLoader->getByPath(string $path, $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
path | string | |
options (optional) | array, bool | array of options (below), or specify boolean for $useLanguages option only.
|
Return value
Page
int
See Also
PagesLoader methods and properties
API reference based on ProcessWire core version 3.0.236