Contao News Sync

inspiredminds/contao-news-sync

von inspiredminds

Project web site: Contao News Sync

This extension allows you to synchronsize news articles between different Contao instances. The direction of synchronisation can be configured freely (i.e. A to B, B to A, or bi-directional). The extension can also be used to import news articles from another Contao installation just once, e.g. when relaunching a website. Since the extension is compatible with Contao 3.5 and 4.4+, it can also be used to import news articles from older Contao versions into newer ones.

Installation

To install this extension, the composer.json of your Contao installation has to be modified first. Two adjustments have to be done: adding the private repository & adding the dependency.

To add the repository, add the following to your composer.json:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://token:<YOUR_TOKEN>@packdis.inspiredminds.at/r"
        }
    ]
}

Replace <YOUR_TOKEN> with the repository token you received from inspiredminds.

To add the dependency, add the following to your composer.json:

{
    "require": {
        "inspiredminds/contao-news-sync": "^3.0"
    }
}
View a full example

After making this adjustment, run a composer update on the command line or update your packages via the Contao Manager. Then open the Contao Install Tool to update the database as usual.

Contao 3

In order to install this extension in Contao 3, you need to use the Composer package management extension for Contao 3. You will find the composer.json within the composer/ subdirectory of your Contao 3 installation. Make sure to use "^1.0" as the version requirement of this extension for Contao 3.

If the Composer package management for Contao 3 is not used yet, it needs to be installed first. One way to do it is to install it without migration, especially if you only need it for a one time synchronisation. In that case you can use the following steps:

Composer package management in Contao 3 - expert installation

Configuration

The extension needs to be installed in all Contao instances that are involved in the synchronisation. After installation additional settings will be available under the Synchronisation section within the settings of a news archive.

In order to make the news of a news archive available as the source for snychronisation, the setting Source for synchronisation needs to be enabled.

News Sync settings

In order to fetch news from a news archive of a remote source the Target for synchronisation setting must be enabled. This will provide additional settings. First, the URL of the remote source needs to be configured in Source URL. After saving, the news archives enabled for synchronisation will be available in the News archives setting.

News Sync settings

  • News archives - this will enable the news archives from which news should be fetched from the remote source and put into this news archive.
  • Limit to categories - the synchronisation can be limited to these categories, if the codefog/contao-news_categories extension is used in both installation.1
  • Ignore duplicate aliases - there might be situations where you already have news articles with the same alias as in the source. With this option you can skip these. Otherwise a duplicate will be created.
  • Sync periodically - this enabled the periodic synchronisation via Contao’s cronjob. The synchronisation will be done hourly.
  • Update existing entries - with this setting, any changes in the source of already synchronised entries will also be updated in the target.
  • Target directory - a directory for the synchronised images and attachments needs to be set here.

1 Currently this only works with version 2.x of the news_categories extension.

Synchronisation

The synchronisation on the target can be triggered in three ways.

  • Command: on the command line you can use the vendor/bin/contao-console contao_news_sync:import command.
  • Backend: there is a global operation called Fetch news in the news archive record list.
  • Cronjob: all news archives with enabled periodic synchronisation will be synchronised hourly via Contao’s cronjob.

Security note

All news articles and content elements of all news archives that have been enabled as a source for synchronisation will be publicly available through the extension’s API.