travel cost calculator tutorial
by Nils Ulfers
- con4gis.io tariff: >= lighthouse
- con4gis brick: con4gis/io-travel-costs (IOTravelCostsBundle)
1. create modules in the backend
To create a travel cost calculator, you must first create two modules in the Contao backend. One is the Travel Expense Calculator and the other is the Travel Expense Tariff Module. You are in the module type dropdown under "con4gis".
2. create a travel cost tariff
Afterwards the travel cost tariffs are provided, for this click in the Contao menu on "tariffs". Click on "New Travel Cost Tariff" and select a name for the tariff. Then you have to enter the prices per kilometre.
Then you can make settings for the "Price for time" and time settings.
3. travel cost settings
After now a tariff was created we occupy ourselves with the travel cost settings. Click on "Settings" in the Contao menu. Click on "New travel cost setting" and define a name for the settings.
Limitation by bounding box
The catchment area for the travel cost calculation can be limited by a bounding box, which means that the tariff calculation is only available in a certain area. To limit the range click on the Geopicker icon and select the limits for the left, lower, right and upper latitude.
In order to link the previously created tariffs with the settings, we must now select the tariffs.
In the settings for the interface you can choose which buttons should be displayed in the frontend afterwards. In addition, you can also set the type of cost calculation and the number of address suggestions.
In this step, a focus can be placed on a center on which the search should focus. Selecting the center is similar to selecting the bounding box using the Geopicker . Here you have to select a longitude and a latitude in the Geopicker to define the center.
In the user-defined settings, you can enter texts for error messages in the frontend yourself. This includes error messages such as "The address you are looking for is outside the catchment area" or errors in the address search "No address was found for your search".
Furthermore a placeholder in the search field, a language and the currency of the tariffs can be selected.
Description of tariffs
To give the user information about the applied tariffs, a description can be added here. To select the user-defined tariff description, the radio button "user-defined display" must be selected.
You can also select whether the tariff description should always be displayed permanently in the frontend or only be added after the tariff has been calculated.
4. include modules in the article
The last step is to integrate the modules you created at the beginning into your site. In the Contao menu item "Articles" on your desired page, create a new element with "Element type" "Module" and your module "Travel cost calculator". The same applies to the module "Travel Cost Tariffs". After saving, the travel cost calculator will be on your page with all the settings you made before.
Have fun with your travel cost calculator!