承接 zeroseven/z7-countries 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

zeroseven/z7-countries

Composer 安装命令:

composer require zeroseven/z7-countries

包简介

This TYPO3 extension offers the possibility of a flexible country configuration for single tree content.

README 文档

README

This TYPO3 extension offers the possibility of a flexible country configuration for single tree content.

Languages that exist in TYPO3 can be split up to match single countries. You can therefore limit content of different languages to only be displayed for chosen countries. For a clean and easy to understand administration in the backend, this extension uses dynamic icons, country filters and more.

Example usage:

Let‘s take the German language. With this extension it’s possible to subdivide the language “German” into the countries “Germany”, “Austria” and “Switzerland” in order to limit selected content to individual countries. In this example, in addition to the German language URL of the website (example.com/de/schweiz), other URLs are automatically available:

  • example.com/de-de/schweiz
  • example.com/de-at/schweiz
  • example.com/de-ch/schweiz

Now, if a content element, a page or any other database record has exclusively been made available for the country Switzerland, it would only be available under example.com/de-ch/schweiz (note the de-ch) but not on the other example urls.

In this example, the content restricted to Switzerland could also be available in other translations, so it can be viewed in other languages:

  • example.com/en-ch/switzerland
  • example.com/it-ch/la-suisse
  • example.com/fr-ch/svizzera

How it works:

With every country that is assigned to a language, the language is made available under an additionally altered base URL. This consists of the ISO Code of the language and a country parameter.

When accessing a page with a language country combination like that in the URL, all database queries on configured tables will be made with these country restrictions in mind.

💡 Therefor the href in the site configuration should only contain the language (e.g. "fr" instead of "fr-FR").

SEO:

There’s no need to worry here. Aside from the URLs, the hreflang as well as the lang attribute of the page are getting altered. This way, the search engines find a perfectly fine identifiable and correct country variation. To put it simple: there will be no duplicate content complaints.

Examples for hreflang tags:

<link rel="alternate" hreflang="en" href="https://example.com/path"/>             <!-- english content -->
<link rel="alternate" hreflang="en-AT" href="https://example.com/en-at/path"/>    <!-- english content for Austria -->
<link rel="alternate" hreflang="en-BE" href="https://example.com/en-be/path"/>    <!-- english content for Belgium -->
<link rel="alternate" hreflang="en-CH" href="https://example.com/en-ch/path"/>    <!-- english content for Switzerland -->
<link rel="alternate" hreflang="en-DE" href="https://example.com/en-de/path"/>    <!-- english content for Germany -->
<link rel="alternate" hreflang="de" href="https://example.com/de/path"/>          <!-- german content -->
<link rel="alternate" hreflang="de-AT" href="https://example.com/de-at/path"/>    <!-- german content for Austria -->
<link rel="alternate" hreflang="de-CH" href="https://example.com/de-ch/path"/>    <!-- german content for Switzerland -->
<link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/path"/>    <!-- german content for Germany -->
<link rel="alternate" hreflang="fr" href="https://example.com/fr/path"/>          <!-- french content -->
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr-fr/path"/>    <!-- french content for France-->
<link rel="alternate" hreflang="fr-BE" href="https://example.com/fr-be/path"/>    <!-- french content for Belgium-->
...

For administrators:

Installation:

Get the extension via composer: composer require zeroseven/z7-countries

Configuration:

  1. On root level (uid:0), create a various amount of countries as data records.
  2. Assign countries to the languages via the TYPO3 site config.
  3. Extend desired data record types for restricting to countries. Example:
\Zeroseven\Countries\Service\BackendService::enableConfiguration('tx_news_domain_model_news');

💡 The database analyzer in the install tool will automatically add the needed fields to your database when running it.

Extend country objects

To extend the country object, extend the database table tx_z7countries_country. The country model automatically provides a set, get, has and a is method for each field.

Example:

$country->getMyNewField(); // Returns the value of the field 'my_new_field'
$country->isDemocratic(); // Returns true or false for the field 'democratic'

// Overwrite the title
$country->setTitle('Brand new Zealand');

Country template condition

ViewHelpers

With the extension's own ViewHelpers it's possible to create country dependent structures in a template. For this‚ you can use any parameter that is available in the Country object.

<html xmlns:countries="http://typo3.org/ns/Zeroseven/Countries/ViewHelpers" data-namespace-typo3-fluid="true">
    <countries:if isoCode="IT">🍕</countries:if>

    <countries:if uid="4">🥙</countries:if>

    <countries:if title="Deutschland">🍺</countries:if>

    <countries:if isoCode="FR">
        <countries:then>🥖</countries:then>
        <countries:else>🍞</countries:else>
    </countries:if>
</html>

TypoScript conditions

In the TypoScript setup, settings can be defined depending on the selected country. For this, the Country Model is available for Conditions.

# Define uid of contact page
settings.contactPageUid = 5

# Overwrite page uid for italy
[country.getUid() === 2]
settings.contactPageUid = 8
[global]

# Overwrite page uid for germany and austria
[country.getIsoCode() in ['DE','AT']]
settings.contactPageUid = 12
[global]

Editor:

Adjust country settings for a data record:

If the data record type has been made available for country configuration, the record can now be restricted to specific countries.

restriction

Language/country check:

When creating or editing a data record, there will be checks if it’s even displayed under current country settings in the chosen language. This way, you can avoid any wasted efforts on misleading configuration.

language check

Country filter:

In the list module, there’s a filter available for you. Now you can check which content is available for any chosen country without any effort.

filter" style

Automatic redirect:

When the start page is called up, an attempt is made to redirect the user to a suitable language/country URL according to his browser settings. For this, the following conditions must be met:

  1. The domain is called without any path
  2. The referer has the same URL origin
  3. No bot could be determined

If you want to disable or override the automatic redirects, take a look at TYPO3's middleware API.

Example of disabling the redirect feature:

The configuration must be provided in Configuration/RequestMiddlewares.php of an extension:

return [
    'frontend' => [
        'zeroseven/z7_countries/redirect' => [
            'disabled' => true
        ]
    ]
];

zeroseven/z7-countries 适用场景与选型建议

zeroseven/z7-countries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.9k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 zeroseven/z7-countries 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2021-06-02