FUEL CMS User Guide : Version 1.5.2


My Url Helper

Contains functions to be used with urls. Extends CI's url helper and is autoloaded.

Function Reference [+]

url_to(['$uri'=''], ['$https'=NULL], ['$language'=NULL])

This is just an alias to the normal CI site_url function but was added mainly to prevent conflicts with other systems like Wordpress (yes... sometimes the two need to be integrated). Added simple return if the url begins with http.

Returns

string

Parameters

(string) $uri the URI string
(boolean) $https sets or removes "https" from the URL. Must be set to TRUE or FALSE for it to explicitly work
(boolean) $language sets the language parameter on the URL based on the "language_mode" setting in the FUEL configuration

site_url(['$uri'=''], ['$https'=NULL], ['$language'=NULL])

Site URL which is an alias to the url_to function.

Returns

string

Parameters

(string) $uri the URI string
(boolean) $https sets or removes "https" from the URL. Must be set to TRUE or FALSE for it to explicitly work
(boolean) $language sets the language parameter on the URL based on the "language_mode" setting in the FUEL configuration

current_url(['$show_query_str'=FALSE], ['$lang'=NULL])

Current URL. Added show_query_str parameter.

Returns

string

Parameters

(boolean) $show_query_str determines whether to include query string parameters
(boolean) $lang determines whether to change the language value

uri_path(['$rerouted'=TRUE], ['$start_index'=0], ['$strip_lang'=TRUE])

Returns the uri path normalized.

Returns

string

Parameters

(boolean) $rerouted use the rerouted URI string?
(boolean) $start_index the start index to build the uri path
(boolean) $strip_lang determines whether to strip any language segments

uri_segment('$n', ['$default'=FALSE], ['$rerouted'=TRUE], ['$strip_lang'=TRUE])

Returns the uri segment.

Returns

string

Parameters

(int) $n the segment number
(string) $default the default value if the segment doesn't exist
(boolean) $rerouted whether to use the rerouted uri
(boolean) $strip_lang determines whether to strip any language segments

is_http_path('$path')

Helper function to determine if it is a local path.

Returns

string

Parameters

(string) $path URL

is_home(['$uri_path'=NULL])

Determines if the page is the homepage or not.

Returns

boolean

is_404()

Determines if the page is 404.

Returns

boolean

last_url(['$default'=FALSE], ['$only_uri'=FALSE])

Returns the last page you visited.

Returns

boolean

Parameters

(string) $default Default value if no last page exists
(boolean) $only_uri Whether to return only the URI part of the the URL

Will return a target="_blank" if the link is not from the same domain.

Returns

boolean

Parameters

(string) $link URL
(array) $exts An array of extensions to check to force it to target="_blank"

redirect_404(['$redirect'=TRUE])

Checks the redirects before showing a 404.

Returns

void

Parameters

(boolean) $redirect Whether to redirect or not

redirect(['$uri'=''], ['$method'='location'], ['$http_response_code'=302], ['$https'=NULL], ['$language'=FALSE])

Header Redirect (Overwritten to account for adding HTTPS and adding language path in site_url function). Header redirect in two flavors For very fine grained control over headers, you could use the Output Library's set_header() function.

Returns

string

Parameters

(string) $uri the URL
(string) $method the method: location or redirect
(string) $http_response_code the http response code
(string) $https wether to force or not https
(boolean) $language wether add the language to the URI

is_https()

Is HTTPS?. Determines if the application is accessed via an encrypted (HTTPS) connection.

Returns

bool

query_str([$exclude=array()], ['$include_post'=FALSE], ['$include_q'=TRUE])

Returns a query string formatted.

Returns

string

Parameters

(array) $exclude an array of query string parameters to exclude
(boolean) $include_post determines whether to include posted variables in the query string
(boolean) $include_q determines whether to include the question mark