Multi-Contexts

Configuration

To change the contexts of your Novius OS instance, edit the local/config/contexts.config.php file.

Default configuration

After installation, Novius OS is configured with three contexts, one site in three languages:

<?php
return array(
        'sites' => array(
                'main' => array(
                        'title' => 'Main site',
                        'alias' => 'Main',
                ),
        ),

        'locales' => array(
                'fr_FR' => array(
                        'title' => 'Français',
                        'flag' => 'fr',
                ),
                'en_GB' => array(
                        'title' => 'English',
                        'flag' => 'gb',
                ),
                'ja_JP' => array(
                        'title' => '日本語',
                        'flag' => 'jp',
                ),
        ),

        'contexts' => array(
                'main::en_GB' => array(),
                'main::fr_FR' => array(),
                'main::ja_JP' => array(),
        ),
);

Multi-sites / multi-languages

Here is an example configuration with five contexts across three sites and three languages:

<?php
return array(
        'sites' => array(
                'main' => array(
                        'title' => 'Main site',
                        'alias' => 'main',
                ),
                'mobile' => array(
                        'title' => 'Mobile site',
                        'alias' => 'Mobile',
                ),
                'event' => array(
                        'title' => 'Event site',
                        'alias' => 'Event',
                ),
        ),

        'locales' => array(
                'en_GB' => array(
                        'title' => 'English',
                        'flag' => 'gb',
                ),
                'fr_FR' => array(
                        'title' => 'Français',
                        'flag' => 'fr',
                ),
                'es_ES' => array(
                        'title' => 'Español',
                        'flag' => 'es',
                ),
        ),

        'contexts' => array(
                'main::en_GB' => array(),
                'main::fr_FR' => array(),
                'main::es_ES' => array(),
                'mobile::fr_FR' => array(),
                'event::en_GB' => array(),
        ),
);

One site in one language

Here is an example configuration for just one site in one language:

<?php
return array(
        'sites' => array(
                'main' => array(
                        'title' => 'Main site',
                        'alias' => 'main',
                ),
        ),

        'locales' => array(
                'en_GB' => array(
                        'title' => 'English',
                        'flag' => 'gb',
                ),
        ),

        'contexts' => array(
                'main::en_GB' => array(),
        ),
);

Domain Names

By default, the first context will answer to the root of your domain, the following contexts in a site_code/language_code/ subdirectory (e.g.: main/es_ES/).

But for each context, you can choose the URI (including a domain and optionally a directory) it will answer to, by specifying it the the associated configuration array.

Contexts on subdirectory

    <?php

'contexts' => array(
    'main::en_GB' => array(), // Uses the default domain
    'main::fr_FR' => array(
        'http://www.mysite.com/fr/',
    ),
    'main::es_ES' => array(
        'http://www.mysite.com/es/',
    ),
    'mobile::fr_FR' => array(
        'http://www.mysite.com/mobile/',
    ),
    'event::en_GB' => array(
        'http://www.mysite.com/event/',
    ),
),

Warning

If your main context (the first) has a fr/example.html page and your main::fr_FR context has an example.html page, their URLs are identical (ie: http://www.mysite.com/fr/example.html). In this situation, only the page of your main context will be accessible.

Contexts on domains

<?php

'contexts' => array(
    'main::en_GB' => array(
        'http://www.monsite.com/',
    ),
    'main::fr_FR' => array(
        'http://www.mysite.fr/',
    ),
    'main::es_ES' => array(
        'http://www.monsite.es/',
    ),
    'mobile::fr_FR' => array(
        'http://mobile.monsite.fr/',
    ),
    'event::en_GB' => array(
        'http://event.monsite.com/',
    ),
),

Note

Of course, your domains should also be properly configured in Apache.

Contexts with multiple URLs

<?php
'contexts' => array(
        'main::en_GB' => array(
                'http://www.monsite.com/',
        ),
        'main::fr_FR' => array(
                'http://www.mysite.fr/',
        ),
        'main::es_ES' => array(
                'http://www.monsite.es/',
        ),
        'mobile::fr_FR' => array(
                'http://mobile.monsite.fr/',
                'http://www.monsite-mobile.fr/',
                'http://www.mysite.com/mobile/',
        ),
        'event::en_GB' => array(
                'http://event.monsite.en/',
        ),
),

Going live

You will probably need to define, for each of your contexts, different URLs between your local (development) and production instances. You can do that using environment-specific config files.

Read the Docs v: chiba.2
Versions
rel_d
latest
chiba.2
chiba.1
0.2
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.