contextualcode/site-link-bundle

eZ Platform / eZ Publish bundle to fix cross-siteaccess links, linking media types, etc.

Installs: 11 828

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 1

Type:symfony-bundle

v3.3.0 2023-10-05 13:32 UTC

README

This is an eZ Platform / eZ Publish 5 Symfony bundle to fix cross-siteaccess links, linking media types, etc.

Installation

Run composer require:

$ composer require contextualcode/site-link-bundle

Enable the bundle in app/AppKernel.php (ezpublish/EzPublishKernel.php) by adding this line in the registerBundles method:

    public function registerBundles()
    {
        $bundles = array(
            ...
            new ContextualCode\SiteLinkBundle\ContextualCodeSiteLinkBundle(),
            ...
        );

Usage

Usage is automatic once the bundle is enabled and configured.

You can use site-link-cross-siteaccess parameter to disable cross siteaccess linking. For example:

{{ path( 'ez_urlalias', { 'locationId': 2, 'site-link-cross-siteaccess': false }) }}
$router->generate('ez_urlalias', ['locationId' => 2, 'site-link-cross-siteaccess' => false]);

Sample config entry

The bundle contains a few options that can be configured in config.yml. For example:

contextual_code_site_link:
    siteaccess_host_match_method: "first"

    internal_external:
        - class_identifier: link
          external_attribute_identifier: external_link
          internal_attribute_identifier: internal_link
        - class_identifier: banner
          external_attribute_identifier: external_link
          internal_attribute_identifier: internal_link

    direct_file_link:
        - class_identifier: file
          attribute_identifier: file

    direct_image_link:
        - class_identifier: image
          attribute_identifier: image
  • siteaccess_host_match_method: either "none", "first", or "best". This controls how cross-siteaccess linking will be handled. "first" will use the first domain available in your siteaccess config. "best" will use the domain from the siteaccess with the most matching parts as the current domain.

  • internal_external: expects an array, each with class_identifier, optional external_attribute, and optional internal_attribute. Will treat these as "link externally if possible, and if not, link to the internal content id".

  • direct_file_link: expects an array, each with class_identifier and attribute_identifier to a File field type. Links to these objects will link directly to the /content/download file link.

  • direct_image_link: Same as direct_file_link, but will link directly to the image.