How to update current url of view page so that it will filter correct result? I have created view to search nodes of video from content type channel. I have set the URL as channel/%/search in view. when redirected to the page the the URL will be channel/all/channel-search?title=test. But I want to replace 'all' with 'nid' which I have got by php code. In short I want to replace channel/all/channel-search?title=test with channel/*NID*/channel-search?title=test (nid may be anything channel/26). I have written the code in views contextual filter but it is not working.

$path = $_SERVER['HTTP_REFERER'];
$filter = preg_replace('///','',parse_url($path,PHP_URL_PATH),1);
$path = drupal_lookup_path("source", $filter);
$node = menu_get_object("node", 1, $path);
$nid=$node-&gt;nid;
return $nid;
Add a new contextual filter, select 'Node: Nid', then check 'Provide default value' and in the select box choose 'Content ID from URL'