PHPackages                             zeroseven/z7-countries - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zeroseven/z7-countries

ActiveTypo3-cms-extension[Utility &amp; Helpers](/categories/utility)

zeroseven/z7-countries
======================

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

v2.4.0(2y ago)32.9k5[2 issues](https://github.com/zeroseven/z7_countries/issues)[3 PRs](https://github.com/zeroseven/z7_countries/pulls)GPL-2.0-onlyPHPPHP ^7.4 || ^8.0

Since May 26Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/zeroseven/z7_countries)[ Packagist](https://packagist.org/packages/zeroseven/z7-countries)[ RSS](/packages/zeroseven-z7-countries/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (21)Used By (0)

Countries 🇯🇵 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧 🇩🇪
=================================

[](#countries-jp-us-fr-es-it-ru-gb-de)

**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:
--------------

[](#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:
-------------

[](#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:
----

[](#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:

[](#examples-for-hreflang-tags)

```

...
```

For administrators:
-------------------

[](#for-administrators)

### Installation:

[](#installation)

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

### Configuration:

[](#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

[](#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

[](#country-template-condition)

#### ViewHelpers

[](#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.

```

    🍕

    🥙

    🍺

        🥖
        🍞

```

#### TypoScript conditions

[](#typoscript-conditions)

In the TypoScript setup, settings can be defined depending on the selected country. For this, the `Country` Model is available for [Conditions](https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Conditions/Index.html).

```
# 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:
-------

[](#editor)

### Adjust country settings for a data record:

[](#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](./Documentation/Images/restriction.png)](./Documentation/Images/restriction.png)

### Language/country check:

[](#languagecountry-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](./Documentation/Images/language_check.png)](./Documentation/Images/language_check.png)

### Country filter:

[](#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](./Documentation/Images/filter.png)](./Documentation/Images/filter.png)

Automatic redirect:
-------------------

[](#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](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestHandling/Index.html#override-ordering-of-middlewares).

### Example of disabling the redirect feature:

[](#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
        ]
    ]
];
```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance46

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~93 days

Total

19

Last Release

935d ago

Major Versions

v0.8.0 → v1.0.02022-03-08

v1.0.0 → v2.0.02022-03-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b22f8a50cfbda138fd9d18f9a9323a9ab93434487122956978e804dee700876?d=identicon)[zerosevendesignstudios](/maintainers/zerosevendesignstudios)

---

Top Contributors

[![srosskopf](https://avatars.githubusercontent.com/u/17512766?v=4)](https://github.com/srosskopf "srosskopf (2 commits)")

### Embed Badge

![Health badge](/badges/zeroseven-z7-countries/health.svg)

```
[![Health](https://phpackages.com/badges/zeroseven-z7-countries/health.svg)](https://phpackages.com/packages/zeroseven-z7-countries)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[typo3/cms-redirects

TYPO3 CMS Redirects - Create manual redirects, list existing redirects and automatically createredirects on slug changes.

167.0M55](/packages/typo3-cms-redirects)[eliashaeussler/typo3-form-consent

Extension for TYPO3 CMS that adds double opt-in functionality to EXT:form

1481.0k](/packages/eliashaeussler-typo3-form-consent)[leuchtfeuer/locate

Locate - The users country, preferred language and other facts will be detected. Depending on configurable rules the user can be redirected to other languages or pages. Locate also provides geo blocking for configurable pages in configurable countries.

1182.8k](/packages/leuchtfeuer-locate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
