Blog Sections Open

Choosing the Right System Event for Region Switching

If a region switch is driven by URL parameters, the best event is the one that sees the request early enough to store the choice before page-specific logic depends on it.

Some Evolution CMS projects keep region state in the session rather than in contexts or separate sites. In that setup, a link like ?region=moscow must be processed early enough that the chosen region is available to the rest of the page logic.

Typical logic

if (isset($_GET['region']) && $_GET['region'] != $_SESSION['region']) {
    if ($_GET['region'] == 'moscow') {
        $_SESSION['region'] = 'moscow';
    } else {
        $_SESSION['region'] = '';
    }
}

What matters most

The exact event should be chosen based on when downstream snippets and templates need the region value. The more your site depends on it during routing or content selection, the earlier in the request flow this logic should run.

Recommendation

Treat region switching as a request-level concern, not a random template trick. The session write should happen before content-building logic begins.

Newer post

Adding a Preview Image to Blog Listing Cards in Evolution CMS

A blog listing becomes easier to scan once each post has a dedicated preview image strategy instead of relying only on text.

Older post

Creating Resources from eForm Data with docBuilder

Turning a form submission into a new resource becomes much easier when the field-to-document mapping is declared in one readable array.