Tools_Context

class Nos\Tools_Context

Provides static methods to work with yours contexts, sites and languages.

See also

Multi-Contexts

::contexts()

static Nos\Tools_Context::contexts
Returns:An array of all your valid contexts.
<?php
$contexts = \Nos\Tools_Context::contexts();
foreach ($contexts as $context_code => $context_urls) {
        // ....
}

::sites()

static Nos\Tools_Context::sites
Returns:An array of all your valid sites. Each site has a title and an alias.
<?php
$sites = \Nos\Tools_Context::sites();
foreach ($sites as $site_key => $site_params) {
        $title = $site_params['title'];
        $alias = $site_params['alias'];
}

::locales()

static Nos\Tools_Context::locales
Returns:An array of all your valid locales. Each locale has a title and a flag’s code flag.
<?php
$locales = \Nos\Tools_Context::locales();
foreach ($locales as $locale_key => $locale_params) {
        $title = $locale_params['title'];
        $flag = $locale_params['flag'];
}

::defaultContext()

static Nos\Tools_Context::defaultContext
Returns:The code of default context of your Novius OS instance.
<?php
$default_context_code = \Nos\Tools_Context::defaultContext();

::locale($container)

static Nos\Tools_Context::locale($container)
Parameters:
  • $container (string) – A context code.
Returns:

Array of context’s locale.

<?php
$locale = \Nos\Tools_Context::locale('main::en_GB');
$title = $locale['title'];
$code_flag = $locale['flag'];

::site($container)

static Nos\Tools_Context::site($container)
Parameters:
  • $container (string) – A context code.
Returns:

Array of context’s site.

<?php
$site = \Nos\Tools_Context::site('main::en_GB');
$title = $site['title'];
$alias = $site['alias'];