Skip to main content
added 223 characters in body
Source Link
petergus
  • 702
  • 10
  • 29

Thank you J. Reynolds for pointing me in the right direction!

I have used the following in "When the filter value is NOT available > provide a default argument > PHP Code"

$url = $_SERVER["REQUEST_URI"];
$url_path = parse_url($url, PHP_URL_PATH);
$basename = pathinfo($url_path, PATHINFO_BASENAME);
return $basename;

($basename is matching the last segment of the URL which is set via pathauto from a custom pseudo title field on my content type, and this field is also used the operational contextual filter in Views.)

enter image description here

EDIT: I also have a Relationship "Content referencing Content from field_related_products" that is selected in the contextual filter.

Please refer to the answer from Ankit Agrawal for a better way to retrieve the URL

Thank you J. Reynolds for pointing me in the right direction!

I have used the following in "When the filter value is NOT available > provide a default argument > PHP Code"

$url = $_SERVER["REQUEST_URI"];
$url_path = parse_url($url, PHP_URL_PATH);
$basename = pathinfo($url_path, PATHINFO_BASENAME);
return $basename;

($basename is matching the last segment of the URL which is set via pathauto from a custom pseudo title field on my content type, and this field is also used the operational contextual filter in Views.)

enter image description here

Thank you J. Reynolds for pointing me in the right direction!

I have used the following in "When the filter value is NOT available > provide a default argument > PHP Code"

$url = $_SERVER["REQUEST_URI"];
$url_path = parse_url($url, PHP_URL_PATH);
$basename = pathinfo($url_path, PATHINFO_BASENAME);
return $basename;

($basename is matching the last segment of the URL which is set via pathauto from a custom pseudo title field on my content type, and this field is also used the operational contextual filter in Views.)

enter image description here

EDIT: I also have a Relationship "Content referencing Content from field_related_products" that is selected in the contextual filter.

Please refer to the answer from Ankit Agrawal for a better way to retrieve the URL

Source Link
petergus
  • 702
  • 10
  • 29

Thank you J. Reynolds for pointing me in the right direction!

I have used the following in "When the filter value is NOT available > provide a default argument > PHP Code"

$url = $_SERVER["REQUEST_URI"];
$url_path = parse_url($url, PHP_URL_PATH);
$basename = pathinfo($url_path, PATHINFO_BASENAME);
return $basename;

($basename is matching the last segment of the URL which is set via pathauto from a custom pseudo title field on my content type, and this field is also used the operational contextual filter in Views.)

enter image description here