Can someone please help me with this, it is important for me...

Here's the case:

In my site i use a lot of views with contextual filters, my links are therefore like https://www.example.com/foo/foo/999 where 999 is the number of a user profile ID

What i want is to get the 999 variable out of this URL to put it as a value in a redirect rule.

I already have a "Check path" in my rule with the "contains" option because the "begins with" option doesn't seem to work, although i have done it exactly as described on the "path rules" module homepage this condition won't get a TRUE.

What to do?
Thanks...
Nielsvoo

Comments

nielsvoo’s picture

if someone else is trying to do this...

I fixed it using php in a custom token with some php code to get the variable out of the URL, by adding this custom token to the $site token part it is always available in my site as global token.

here is the code for the Token

<?php
	$url = (!empty($_SERVER['HTTPS'])) ? 
	"https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : 
	"http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
	$parts = parse_url($url);
	$path_parts= explode('/', $parts[path]);
	$user = $path_parts[2];
	echo $user; // **echo's third part of url**
?>

Nielsvoo

Richard15’s picture

Some solutions are:
$path_args = explode('/', request_path());
$path_uri = explode('/', request_uri());