Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Skip to end of metadata
Go to start of metadata

Version compatibility

This page is compatible with eZ Publish 5.3 / 2014.03

 

When using the multisite feature, it is sometimes useful to be able to generate cross-links between the different sites.
This allows to link different resources referenced in a same content repository, but configured independently with different tree roots.

Twig example
See ez_urlalias documentation page
PHP example
 
Important: As SiteAccess matchers can involve hosts and ports, it is highly recommended to generate cross-siteaccess
links in the absolute form (e.g. using url() Twig helper).
  • The first matcher succeeding always wins, so be careful when using catch-all matchers like URIElement.
  • If passed SiteAccess name is not a valid one, an InvalidArgumentException will be thrown.
  • If matcher used to match provided SiteAccess doesn't implement VersatileMatcher, the link will be generated for the current SiteAccess.
  • When using Compound\LogicalAnd, all inner matchers must match. If at least one matcher doesn't implement VersatileMatcher, it will fail.
  • When using Compound\LogicalOr, the first inner matcher succeeding will win.

To implement this feature, a new VersatileMatcher was added to allow SiteAccess matchers to be able to reverse-match.
All existing matchers implement this new interface, except the Regexp based matchers which have been deprecated.

The SiteAccess router has been added a matchByName() method to reflect this addition. Abstract URLGenerator and DefaultRouter have been updated as well.

Note: SiteAccess router public methods have also been extracted to a new interface, SiteAccessRouterInterface.

1 Comment

  1. Unknown User (pr pr)

    Hi, in the PHP code example, since you meant to generate absolute URL's, you need to pass the constant UrlGeneratorInterface::ABSOLUTE_URL to $this->generateUrl instead of UrlGeneratorInterface::ABSOLUTE_PATH.