UrlHelper
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\UrlHelper
- Since
- 1.0
Class UrlHelper
See also http://craftcms.com
View source (opens new window)
# Public Methods
| Method | Description |
|---|---|
| getActionUrl() | |
| getCpUrl() | Returns a CP URL. |
| getProtocolForTokenizedUrl() | Returns what the protocol/schema part of the URL should be (http/https) for any tokenized URLs in Craft (email verification links, password reset urls, share entry URLs, etc. |
| getResourceUrl() | Returns a resource URL. |
| getSiteUrl() | Returns a site URL. |
| getUrl() | Returns either a CP or a site URL, depending on the request type. |
| getUrlWithParams() | Returns a URL with additional query string parameters. |
| getUrlWithProtocol() | Returns a URL with a specific protocol. |
| getUrlWithToken() | Returns a URL with a 'token' query string param set to a given token. |
| isAbsoluteUrl() | Returns whether a given string appears to be an absolute URL. |
| isFullUrl() | Returns whether a given string appears to be a "full" URL (absolute, root-relative or protocol-relative). |
| isProtocolRelativeUrl() | Returns whether a given string appears to be a protocol-relative URL. |
| isRootRelativeUrl() | Returns whether a given string appears to be a root-relative URL. |
| stripQueryString() | Removes the query string from a given URL. |
# getActionUrl()
View source (opens new window)
Arguments
$path(string (opens new window))$params(null (opens new window))$protocol(string (opens new window)) – The protocol to use (e.g. http, https). If empty, the protocol used for the current request will be used.
Returns
Signature
public static array, string getActionUrl ( $path = '', $params = null, $protocol = null )
# getCpUrl()
Returns a CP URL.
View source (opens new window)
Arguments
$path(string (opens new window))$params(array (opens new window), string (opens new window), null (opens new window))$protocol(string (opens new window), null (opens new window))
Returns
Signature
public static string getCpUrl ( $path = '', $params = null, $protocol = null )
# getProtocolForTokenizedUrl()
Returns what the protocol/schema part of the URL should be (http/https) for any tokenized URLs in Craft (email verification links, password reset urls, share entry URLs, etc.
View source (opens new window)
Returns
Signature
public static string getProtocolForTokenizedUrl ( )
# getResourceUrl()
Returns a resource URL.
View source (opens new window)
Arguments
$path(string (opens new window))$params(array (opens new window), string (opens new window), null (opens new window))$protocol(string (opens new window), null (opens new window)) – The protocol to use (e.g. http, https). If empty, the protocol used for the current request will be used.
Returns
Signature
public static string getResourceUrl ( $path = '', $params = null, $protocol = null )
# getSiteUrl()
Returns a site URL.
View source (opens new window)
Arguments
$path(string (opens new window))$params(array (opens new window), string (opens new window), null (opens new window))$protocol(string (opens new window), null (opens new window))$localeId(string (opens new window), null (opens new window))
Returns
Signature
public static string getSiteUrl ( $path = '', $params = null, $protocol = null, $localeId = null )
# getUrl()
Returns either a CP or a site URL, depending on the request type.
View source (opens new window)
Arguments
$path(string (opens new window))$params(array (opens new window), string (opens new window), null (opens new window))$protocol(string (opens new window), null (opens new window))$mustShowScriptName(boolean (opens new window))
Returns
Signature
public static string getUrl ( $path = '', $params = null, $protocol = null, $mustShowScriptName = false )
# getUrlWithParams()
Returns a URL with additional query string parameters.
View source (opens new window)
Arguments
$url(string (opens new window))$params(array (opens new window), string (opens new window))
Returns
Signature
public static string getUrlWithParams ( $url, $params )
# getUrlWithProtocol()
Returns a URL with a specific protocol.
View source (opens new window)
Arguments
$url(string (opens new window))$protocol(string (opens new window))
Returns
Signature
public static string getUrlWithProtocol ( $url, $protocol )
# getUrlWithToken()
Returns a URL with a 'token' query string param set to a given token.
View source (opens new window)
Arguments
$url(string (opens new window))$token(string (opens new window))
Returns
Signature
public static string getUrlWithToken ( $url, $token )
# isAbsoluteUrl()
Returns whether a given string appears to be an absolute URL.
View source (opens new window)
Arguments
$url(string (opens new window))
Returns
Signature
public static boolean isAbsoluteUrl ( $url )
# isFullUrl()
Returns whether a given string appears to be a "full" URL (absolute, root-relative or protocol-relative).
View source (opens new window)
Arguments
$url(string (opens new window))
Returns
Signature
public static boolean isFullUrl ( $url )
# isProtocolRelativeUrl()
Returns whether a given string appears to be a protocol-relative URL.
View source (opens new window)
Arguments
$url(string (opens new window))
Returns
Signature
public static boolean isProtocolRelativeUrl ( $url )
# isRootRelativeUrl()
Returns whether a given string appears to be a root-relative URL.
View source (opens new window)
Arguments
$url(string (opens new window))
Returns
Signature
public static boolean isRootRelativeUrl ( $url )
# stripQueryString()
Removes the query string from a given URL.
View source (opens new window)
Arguments
$url– The URL to check.
Returns
string (opens new window) – The URL without a query string.
Signature
public static string stripQueryString ( $url )