pixelant/pxa-site-choice-recommendation 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

pixelant/pxa-site-choice-recommendation

Composer 安装命令:

composer require pixelant/pxa-site-choice-recommendation

包简介

Suggest localized version of site depends on user location and user language.

README 文档

README

What does it do?

Suggest localized version of site depends on user location and user language. It will show bar on top of the page with possibility to choose site language. Select box options are sorted by priority calculated by checking user location and accept language.

Note: To get option based on user location, a EventListner needs to be created in a separate extension.

How to install it

Like a regular extension you need to do a few steps.

  1. Composer install composer require pixelant/pxa-site-choice-recommendation
  2. Go to extension manager to isntall extension.
  3. Include TypoScript. There are two options to include:
    • Site choice recommendation - default configuration required for extension to work
    • Site choice JS and CSS assets - will include Js and Css libs

Extension plugins

Extension has two plugins:

  1. Choice bar extension - Loaded by ajax to propose user to change site version. Can't be added on a page.
  2. Site choice recommendation splash page - Use as page content in order to show for user ALL available choices. Just select corresponding site choice configuration in order to show it's options.

How to create site choice configuration

Create new record "Site Choice Configuration". It could be created in any storage folder. "Site Choice Configuration" tabs: Main "General" tab:

  • Name - just whatever you want
  • Connect to sites - choose rootpages where bar should appear
  • Max Items - maximum items in select box in bar
  • Splash pages links - splash page link for every root page. Each root page might have it's own splash page.

"Choices" tab include available site choices for bar and splash page. Each site choice require next configration fields:

  • Title - title of choice. It's text area because it could have different versions(localizations) of title. You could specify different localization versions each in new row in a format "Title text|locale":
Default title
Swedish title|sv_SE
Ukrainian title|uk_UA
  • Flag - flag icon to show in select box and splash page
  • Select country - select country. This field represents ISO code (for ex. "us" for USA). This code will be used when check if choice match by user IP. ISO codes
  • Select language - select language from list. This field represents short ISO code (for ex. "en" for English). This code will be used for check by user language.
  • Link - if choice target to external url
  • Language layer - if choice should lead to site langauge layer. Link need to be empty if language layer is used.

Expected results

After TypoScript is included and Site Choice Configuration is connected to root page, you should get bar with proposal of best matching country / region based on location. Note: bar will remain invisible in case you already has visited website localization version that best match you location/language.

Enable choices based on user location

Extension has "built in" support to suggest options based on user location.

To enable it, you will need to create a EventListner in a separate extension and also download GeoLite2-Country.mmdb from MaxMind, available from https://www.maxmind.com.

Example:

1. Registering the event listener

Following is an example of how to enable the IPDetecor.

In file your_extension_name/Configuration/Services.yaml file add following:

  VendorName\YourExtensionName\EventListener\IpDetectorFactoryEvent:
    tags:
      - name: event.listener
        identifier: 'yourExtensionNameIpDetectorFactoryEvent'
        event: Pixelant\PxaSiteChoiceRecommendation\Detector\Event\AddDetectorFactoryEvent
        after: acceptLanguageDetectorFactoryEvent

2. The event listener class

Create file your_extension_name/Classes/EventListener/IpDetectorFactoryEvent.php file add following:

<?php

declare(strict_types=1);

namespace VendorName\YourExtensionName\EventListener;

use Pixelant\PxaSiteChoiceRecommendation\Detector\Event\AddDetectorFactoryEvent;
use Pixelant\PxaSiteChoiceRecommendation\Detector\Factory\IpDetectorFactory;

/**
 * Adds IpDetector to Detectors.
 */
final class IpDetectorFactoryEvent
{
    public function __invoke(AddDetectorFactoryEvent $event)
    {
        // Add IP Detector.
        $event->addDetectorFactoryCreators(IpDetectorFactory::class);
        // Set path to GeoLite2-Country.mmdb.
        $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['pxa_site_choice_recommendation']['countryDbPath']
            = 'EXT:your_extension_name/Resources/Private/GeoIp2/GeoLite2-Country.mmdb';
    }
}

3. GeoLite2-Country dababase

Download GeoLite2-Country.mmdb from MaxMind and save in folder: your_extension_name/Resources/Private/GeoIp2/GeoLite2-Country.mmdb.

pixelant/pxa-site-choice-recommendation 适用场景与选型建议

pixelant/pxa-site-choice-recommendation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 pixelant/pxa-site-choice-recommendation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pixelant/pxa-site-choice-recommendation 我们能提供哪些服务?
定制开发 / 二次开发

基于 pixelant/pxa-site-choice-recommendation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2019-04-15