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

Returns

array (opens new window), string (opens new window)

Signature

public static array, string getActionUrl ( $path = '', $params = null, $protocol = null )

# getCpUrl()

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

string (opens new window)

Signature

public static string getProtocolForTokenizedUrl ( )

# getResourceUrl()

Returns a resource URL.

View source (opens new window)

Arguments

Returns

string (opens new window)

Signature

public static string getResourceUrl ( $path = '', $params = null, $protocol = null )

# getSiteUrl()

Signature

public static string getSiteUrl ( $path = '', $params = null, $protocol = null, $localeId = null )

# getUrl()

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

Returns

string (opens new window)

Signature

public static string getUrlWithParams ( $url, $params )

# getUrlWithProtocol()

Returns a URL with a specific protocol.

View source (opens new window)

Arguments

Returns

string (opens new window)

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

Returns

string (opens new window)

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

Returns

boolean (opens new window)

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

Returns

boolean (opens new window)

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

Returns

boolean (opens new window)

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

Returns

boolean (opens new window)

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 )