se7enxweb / ezurlmultisite
Exponential kernel override extension featuring template operator php class overrides that replace at runtime the template operators like ezurl and ezroot to bind content trees to siteaccess host names for true multisite content object resolution to url routes. Great for all large content websites a
Package info
github.com/se7enxweb/ezurlmultisite
Type:ezpublish-legacy-extension
pkg:composer/se7enxweb/ezurlmultisite
Fund package maintenance!
Requires
- php: >=5.0.0
- se7enxweb/exponential-legacy-installer: *
This package is auto-updated.
Last update: 2026-07-19 09:55:19 UTC
README
Kernel class override for Exponential / Exponential Platform Legacy that extends the
built-in ezurl template operator with multi-siteaccess link handling and a
number of optional sitelink-inspired features, while keeping the original
ezurl API intact.
What it does
In a multi-site installation ezurl normally only prepends the index path and
quotes the input. It does not know that a relative URL such as
websites/sole-kracker-org/foo or slashnews might belong to a different
siteaccess and must be rendered as an absolute URL on the correct host.
This extension overrides eZURLOperator so ezurl can, without template
changes:
- Detect a different target siteaccess from a
PathPrefixmatch. - Fall back to resolving the content node from the URL alias to determine the target siteaccess.
- Build the correct
http(s)://<SiteURL>/<path>output when linking across siteaccesses. - Leave local/internal links unchanged.
- Accept an optional third
parametershash with extra options such asabsolute,siteaccess,hash,query,no_self_link,protocol, etc.
It also registers three new operators for advanced use:
ezurl_pathezurl_siteaccessezurl_roots
Requirements
- eZ Publish 4.x / eZ Platform Legacy 2017+
eZURLOperatorkernel class override support enabledEZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDEenabled inconfig.phpfor the kernel override layer
Installation
- Copy or clone this extension to
extension/ezurlmultisite. - Add the extension to
settings/override/site.ini.append.php:
[ExtensionSettings]
ActiveExtensions[]=ezurlmultisite
- Regenerate autoload arrays:
php bin/php/ezpgenerateautoloads.php --extension php bin/php/ezpgenerateautoloads.php --kernel-override
- Clear caches:
php bin/php/ezcache.php --allow-root-user --clear-tag=ini php bin/php/ezcache.php --allow-root-user --clear-tag=template
File layout
extension/ezurlmultisite/
├── autoloads/
│ └── eztemplateautoload.php
├── classes/
│ ├── ezurlmultisite.php
│ ├── ezurlmultisiteoperator.php
│ ├── ezurlmultisitedatatypehandler.php
│ ├── ezurlmultisiteurlhandler.php
│ ├── ezurlmultisitebinaryfilehandler.php
│ ├── ezurlmultisiteobjectrelationhandler.php
│ └── kerneloverride/
│ └── v2025.01.15/
│ └── kernel/
│ └── common/
│ └── ezurloperator.php
├── settings/
│ └── ezurlmultisite.ini
└── README.md
classes/kerneloverride/.../ezurloperator.phpis the kernel override forkernel/common/ezurloperator.php.classes/ezurlmultisite.phpcontains the shared helper logic.classes/ezurlmultisiteoperator.phpregistersezurl_path,ezurl_siteaccessandezurl_roots.
Basic usage
Templates continue to use |ezurl as before:
<a href={$node.url_alias|ezurl}>...</a>
No template changes are required for the multi-siteaccess fix.
Extended ezurl parameters
The operator keeps the original positional parameters:
{$url|ezurl}
{$url|ezurl('single')}
{$url|ezurl('no','full')}
A third positional parameter, parameters, accepts a hash of advanced options:
{$url|ezurl('double','relative',hash('absolute',true(),'protocol','https'))}
Available parameters
| Key | Type | Description |
|---|---|---|
absolute |
boolean | Force a full absolute URL. |
siteaccess |
string | Force the target siteaccess. |
protocol |
string | Override the URL scheme: http, https, // (protocol-relative), or empty for current scheme. |
hash |
string | Append a URL fragment (#section). |
query |
string or hash | Append a query string; a hash is converted to key=value&.... |
user_parameters |
array | Append eZ Publish view user parameters as /(key)/value segments. |
no_self_link |
boolean | Return an empty string if the link target is the current page. |
node_id |
boolean | When the input is an integer, treat it as a node ID (true, default) or object ID (false). |
link_type |
string | For class-based links, request a specific type such as internal, external or download. |
Examples
{* Force absolute URL *}
<a href={$node.url_alias|ezurl('double','relative',hash('absolute',true()))}>...</a>
{* Force a specific siteaccess *}
<a href={$node.url_alias|ezurl('double','relative',hash('siteaccess','korg_sole'))}>...</a>
{* HTTPS absolute link, with query and fragment *}
<a href={$node.url_alias|ezurl('double','relative',hash('absolute',true(),'protocol','https','query','foo=bar','hash','section'))}>...</a>
{* Pass an integer node ID *}
<a href={$node_id|ezurl('double','relative',hash('node_id',true()))}>...</a>
{* Pass an object ID instead *}
<a href={$object_id|ezurl('double','relative',hash('node_id',false()))}>...</a>
Protocol / HTTPS
The current request scheme is used by default, so an HTTPS page generates
https:// absolute URLs. The protocol option can override this:
{* Protocol-relative URL *}
<a href={$node.url_alias|ezurl('double','relative',hash('absolute',true(),'protocol','//'))}>...</a>
{* Force plain HTTP *}
<a href={$node.url_alias|ezurl('double','relative',hash('absolute',true(),'protocol','http'))}>...</a>
New operators
ezurl_path
Returns the path part of the resolved link, with the target siteaccess prefix stripped.
{def $path = $node.url_alias|ezurl_path()}
ezurl_siteaccess
Returns the name of the siteaccess that should host the given input.
{def $sa = $node.url_alias|ezurl_siteaccess()}
ezurl_roots
Returns an array of root node information per siteaccess. Each element contains
siteaccess, host, prefix and root_node_id.
{def $roots = ezurl_roots()}
Configuration
Settings are in extension/ezurlmultisite/settings/ezurlmultisite.ini. Copy
the file to settings/override/ezurlmultisite.ini.append.php to customize it
safely.
[OperatorSettings]
[OperatorSettings] ForceAbsoluteURL=disabled DefaultLinkType=internal DefaultQuote=double DefaultServerURL=relative RoleOverride=disabled SiteLinkClassList[]
ForceAbsoluteURL=enabledmakes everyezurlcall absolute by default.SiteLinkClassList[]lists class identifiers that should use class-based link generation (see below).
[HostMap]
Override the host used for a siteaccess when site.ini SiteURL is not enough:
[HostMap]
SiteAccess[korg_sole]=sole.example.com
[RoleMap]
Force the target siteaccess for users with a given role. Enable with
RoleOverride=enabled in [OperatorSettings].
[RoleMap]
RoleList[12]=korg_edit
[ClassSettings] and per-class blocks
[ClassSettings] DefaultLinkType=internal SelfLinking=enabled [link] DefaultLinkType=external LinkTypeList[internal]=internal_link LinkTypeList[external]=external_link LinkTypeList[download]=file DataTypeClass=eZURLMultisiteURLHandler
For classes listed in SiteLinkClassList[], ezurl can resolve the link from a
specific attribute. LinkTypeList maps a link type to an attribute identifier,
and DataTypeClass can override the datatype handler used for the attribute.
[PathSettings]
[PathSettings] DisableNodeID=disabled DisableObjectID=disabled NodeIDList[] ObjectIDList[]
When DisableNodeID or DisableObjectID is enabled, listed IDs cause ezurl
to return an empty string.
[DataTypeSettings]
[DataTypeSettings]
HandlerList[ezurl]=eZURLMultisiteURLHandler
HandlerList[ezstring]=eZURLMultisiteURLHandler
HandlerList[ezbinaryfile]=eZURLMultisiteBinaryFileHandler
HandlerList[ezobjectrelation]=eZURLMultisiteObjectRelationHandler
Custom handlers must implement eZURLMultisiteDataTypeHandler.
Datatype handlers
The extension ships with three handlers:
eZURLMultisiteURLHandlerforezurlandezstringattributes.eZURLMultisiteBinaryFileHandlerforezbinaryfileattributes, withdownloadlink type support.eZURLMultisiteObjectRelationHandlerforezobjectrelationattributes, resolving the related object's main node URL alias.
License
Copyright (C) 1998 - 2026 7x
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.