Location based landing page

Since version 2 it is possible to make different configurations and styling for different location or VLANs.

We differentiate between two types of location based configuration. The first is to show different templates and the second is to define different configurations per location. You can mix this two types as you like. The location based functionality has to be enabled in conf/main.cofig.

Configuration key

Default

location-based

false

Activates the location based functionality

location-id-fields

iacbox

Data fields which will be used. Currently available are iacbox which is the
registration number and vlan for the VLAN-ID (or Route-ID in routing mode)

Please note that the IACBOX has to send the needed data for the location. Check your settings in Login page / Login-API settings. The following parameters have to be present in the field First call data fields with placeholders when using location based: vl=$VLAN (location per vlan), iac=$REGNR (location per registration number).

Possible location-id-fields configurations

location-id-fields Configuration

Example

vlan

v10

iacbox

2001010101

iacbox, vlan

2001010101-v10

Show different templates per location

After you enabled the location based functionality switch to the file htdocs/index.php. Comment in the following code part at the end of the file and comment out the last two lines of the code like the example below. Customize the different cases for your needs. Please note that when using VLANs it is necessary to add the letter v before the VLAN-Id.

htdocs/index.php
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

switch ($loginApi->getLocationId()) {
        // The location ID can be the Reg-Nr or the VLAN-ID or a combination - define that in conf/main.config
        case 'v10':
                // only VLAN matching
                include_once('index_view_XXX.php');
                break;
        case '2001010101': /* intentional fall-through */
        case '2001010102': /* intentional fall-through */
        case '2001010103':
                // only a registration number (of course only useful if more than one system connects to this Login-API instance)
                include_once('index_view_YYY.php');
                break;
        case '2001010101-v12':
                // a combination of reg-nr and VLAN-ID
                include_once('index_view_ZZZ.php');
                break;
        default:
                // There are cases where clients without cookie support (or proper redirect) end up here without the
                // needed informations (ip, mac, vlan) so we don't have a location ID - this template here is a fallback
                // that should provide at least the "restore session" button for humans - most of the time this will
                // be hit by apps.
                $template = $loginApi->getTemplateFile();
                include_once($template);
                break;
}

// --- This needs to be out commentet if you want to work location-based
//$template = $loginApi->getTemplateFile();
//include_once($template);
// ---

Show different configurations per location

Location based configurations can be made in all .config files by grouping config values with so called sections which are location IDs in square brackets like [my-location-id].

Attention

Place sections for location based settings always at the bottom of config files because all following config values after a location ID belong only to this location. You should always have a default section at the top without any section header.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
languages = de, en, fr, it

# ... leave all present configs above and add at the end of the file!

[your-location-id]
languages = es, pt, en

# Example location-id-fields = vlan
[v10]
languages = es, pt, en

# Example location-id-fields = iacbox
[2001010101]
languages = es, pt, en

# Example location-id-fields = iacbox, vlan
[2001010101-v10]
languages = es, pt, en

Available configurations:

The following configuration keys are available for the location based functionality in the conf/main.config:

  • company-name

  • company-name-legal

  • company-website

  • logo

  • background-image

  • show-welcome-header

  • show-lang-select

  • template

  • plugins

  • languages

  • fallback-language

  • redirect-url

If you want to group multiple systems or you have your location information in a database you can provide a custom service by implementing the interface Iacbox/LoginApi/Core/LocationService and load that service in the conf/main.config with

1
custom-services = MyLocationService

We are delivering an example implementation with Iacbox/LoginApi/Custom/DBLocationService. It uses a database, but you can develop your own version that connects to a different service.