Trongate Docs
switch to dark modeswitch to dark mode
»
»
The URL Helper

The URL Helper

The URL Helper is a class, stored inside the 'engine' folder, that helps you to perform tasks related to page URLs. The following features are available inside the URL helper:

Current URL

Purpose: Returns the URL of the current page.

Example:

$page_url = current_url();

Previous URL

Purpose: Returns the URL of the previously visited page. This is often called the referrer URL or the HTTP referer.

Example:

$previous_url = previous_url();

BASE URL

Purpose: Returns the base URL of your app. This is usually the URL corresponds with your web app's home page.

Example:

$homepage = BASE_URL;

Segment Getter

Purpose: The segment getter helps you to easily fetch segments from the current page URL. A segment is a string of characters that occur in a URL. Segments are separated by forward-slashes.

Arguments: Accepts one argument: an integer representing the segment number that you would like to fetch.

Example:

If your URL was this,

http://www.website.com/rock/and/roll

then, the code below would assign a value of 'rock' to the $first_segment variable.

$first_segment = segment(1);

Just To Let You Know
In very early versions of Trongate the syntax for reading values from the URL was slightly different. Older versions of Trongate used:

$var = $this->url->segment(3);

As you can see, the code being used today is a little more compact.


HELP & SUPPORT

If you have a question or a comment relating to anything you've see here, please goto the Help Bar.

 
×