PageTraversal::urlOptions()
Returns the URL to the page with $options
You can specify an $options argument to this method with any of the following:
pageNum(int|string|bool): Specify pagination number, "+" for next pagination, "-" for previous pagination, or true for current.urlSegmentStr(string|bool): Specify a URL segment string to append, or true 3.0.155+ for current.urlSegments(array|bool): Specify regular array of URL segments to append (may be used instead of urlSegmentStr). Specify boolean true for current URL segments 3.0.155+. Specify associative array (in 3.0.155+ to make both keys and values part of the URL segment string.data(array): Array of key=value variables to form a query string.http(bool): Specify true to make URL include scheme and hostname Default:falsescheme(string): Like the http option, makes URL include scheme and hostname, but you specify scheme with this, i.e. 'https' 3.0.178+host(string): Hostname to force use of, i.e. 'world.com' or 'hello.world.com'. The 'http' option is implied when host specified. 3.0.178+language(Language): Specify Language object to return URL in that Language.
You can also specify any of the following for $options as shortcuts:
- If you specify an
intfor options it is assumed to be thepageNumoption. - If you specify
+or-for options it is assumed to be thepageNum“next/previous pagination” option. - If you specify any other
stringfor options it is assumed to be theurlSegmentStroption. - If you specify a
boolean(true) for options it is assumed to be thehttpoption.
Please also note regarding $options:
- This method honors template slash settings for page, URL segments and page numbers.
- Any passed in URL segments are automatically sanitized with
Sanitizer::pageNameUTF8(). - If using the
pageNumor URL segment options please also make sure these are enabled on the page’s template. - The query string generated by any
datavariables is entity encoded when output formatting is on. - The
languageoption requires that theLanguageSupportPageNamesmodule is installed. - The prefix for page numbers honors
$config->pageNumUrlPrefixand multi-language prefixes as well.
Usage
// basic usage
$string = $pageTraversal->urlOptions(Page $page);
// usage with all arguments
$string = $pageTraversal->urlOptions(Page $page, $options = []);Arguments
See Also
PageTraversal methods and properties
API reference based on ProcessWire core version 3.0.255