定制 webexcess/redirecthandler-localization 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webexcess/redirecthandler-localization

Composer 安装命令:

composer require webexcess/redirecthandler-localization

包简介

Create shortcuts which get redirected to the matching language and region dimension of the visitor.

README 文档

README

Logo Latest Stable Version License

This package allows to create Neos.RedirectHandler shortcuts which gets redirected to the matching language and region dimension of the visitor.

Installation

composer require webexcess/redirecthandler-localization

Configuration

  • dimensionIdentifiers.linguistic (string)
    • The key of your linguistic dimension, default: 'language'
  • dimensionIdentifiers.regional (string)
    • The key of your regional dimension, default: not set
  • overwriteDefaultDimensionUriSegment (array)
    • A list of "dimensionIdentifier: defaultDimensionUriSegment": default: empty
    • Use this to overwrite the default uri segment per dimension
    • Example: overwriteDefaultDimensionUriSegment.language: 'en'
  • ipinfoToken (string)
    • The token to the ipinfo.io webservice, default: '' (for non-commerical use)
    • Add your own token if you need more than 1,000 requests a day
    • Disable the token, to use the pecl geoip
    • Or implement your very own implementation of the LocalizationInterface

Usage

Instead of adding a speaking url to "target uri path", add the node identifier like: node://ad798967-8662-4c6f-b1d1-4c8188038d23.

flow redirect:add source node://ad798967-8662-4c6f-b1d1-4c8188038d23 302

Or use the WebExcess.RedirectHandler.Backend package.

Simple Example

A site with language dimensions.

Existing dimension configuration

Neos:
  ContentRepository:
    contentDimensions:
      language:
        label: Language
        icon: icon-language
        default: en
        defaultPreset: en
        presets:
          de:
            label: German
            values:
              - de
              - en
            uriSegment: de
          fr:
            label: French
            values:
              - fr
              - en
            uriSegment: fr
          it:
            label: Italian
            values:
              - it
              - en
            uriSegment: it

RedirectHandler.Localization configuration

No configuration needed.

Advanced Example

A site with language and country dimensions which is using ipinfo.io to geolocate the visitors ip address.

Existing dimension configuration

Neos:
  ContentRepository:
    contentDimensions:
      language:
        label: Language
        icon: icon-language
        default: en
        defaultPreset: en
        presets:
          de:
            label: German
            values:
              - de
              - en
            uriSegment: de
          fr:
            label: French
            values:
              - fr
              - en
            uriSegment: fr
          it:
            label: Italian
            values:
              - it
              - en
            uriSegment: it
          # ...
          en:
            label: English
            values:
              - en
            uriSegment: en
      country:
        label: Country
        icon: icon-globe
        default: GLOBAL
        defaultPreset: GLOBAL
        presets:
          GLOBAL:
            label: Global
            values:
              - GLOBAL
            uriSegment: ''
          CH:
            label: Schweiz
            values:
              - CH
              - GLOBAL
            uriSegment: CH
            constraints:
              language:
                '*': false
                de: true
                fr: true
                it: true
                en: true
          DE:
            label: Deutschland
            values:
              - DE
              - GLOBAL
            uriSegment: DE
            constraints:
              language:
                '*': false
                de: true
                en: true
          # ...
          ZA:
            label: 'South Africa'
            values:
              - ZA
              - GLOBAL
            uriSegment: ZA
            constraints:
              language:
                '*': false
                en: true

RedirectHandler.Localization configuration

Objects.yaml

WebExcess\RedirectHandler\Localization\Service\LocalizationInterface:
  className: WebExcess\RedirectHandler\Localization\Service\LanguageAndCountryLocalization

Settings.yaml

WebExcess:
  RedirectHandler:
    Localization:
      dimensionIdentifiers:
        linguistic: 'language'
        regional: 'country'
      overwriteDefaultDimensionUriSegment:
        country: 'CH'
      ipinfoToken: '1234567890'

Custom Example

You can add your own LocalizationInterface implementation.

All you have to return in the getTargetContext function is a valid context array, for example:

Array
(
    [dimensions] => Array
        (
            [language] => Array
                (
                    [0] => de
                    [1] => en
                )

            [country] => Array
                (
                    [0] => CH
                    [1] => GLOBAL
                )

        )

    [targetDimensions] => Array
        (
            [language] => de
            [country] => CH
        )

)

developed by webexcess GmbH

sponsored by Blaser Swisslube AG

统计信息

  • 总下载量: 302
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固