Hi All,

Is country path prefix available as token or session parameter?
Eg. I have nodes not linked to any domain which have country field. Would like to filter nodes in view based on 'country' as per domain country prefix.

Thanks

Comments

monkk created an issue. See original summary.

daniel.j’s picture

Status: Active » Fixed

You can use the Domain Negotiator service and read the third-party setting that country_path stores under country_path:domain_path.

$domain = \Drupal::service('domain.negotiator')->getActiveDomain();
if ($domain) {
  $prefix = $domain->getThirdPartySetting('country_path', 'domain_path');
  // Example: $prefix might be 'uk', 'de', etc.
}

This could then be used in, for example, a 'hook_views_query_alter()' hook to filter as you want.

If this has not aswered your question, please reopen the issue. I do think that it could be easier to access path prefix, perhaps this could be made into a feature request issue.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.