Skip to content

Instantly share code, notes, and snippets.

Last active April 19, 2017 14:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save karlhinze/965da6f6f6441dde4cc19efee2d53893 to your computer and use it in GitHub Desktop.
LiveWhale custom module to save the current URL segments as XPHP variables
// Provide access to each segment of the server path with the variable: <xphp var="url_segment_[x]" />
'title'=>'Server Path',
class LiveWhaleApplicationServerPath {
public function onLoad() { // on module load
global $_LW;
// Get the server path from the url and split it into segments, removing the first slash
$url_segments = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$num_segments = count($url_segments);
// Return global variables for each segement of the server path
for($i = 0; $i <= $num_segments; $i++) {
$j = $i+1;
$GLOBALS['url_segment_'.$j] = @$url_segments[$i];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment