Skip to main content

Can I also display data from an external service?

Imagine you want to build a configurator for prefabricated homes and have a loan calculator. You want to display its results in the configurator.

Calling the Service​

  • Open your configurator’s editor.
  • Click
    Loading...
    in the sidebar.
  • Click
    Loading...
    .
  • Here, you can now specify:
    • A URL to which K3 sends a POST request.
    • A time interval in milliseconds. The system waits at least this long between two requests (debounce).
    • Whether attribute values should be sent.
    • And if so, which ones. An entry here also reduces the number of calls to your service.
    • Whether the item and the current price should be included.

We will then call your service after every user change. As a result, we expect a JSON document with a structure like this:

{
"json": {
"shippingPrice": 123.12,
"dealerCount50Km": "value",
"dealerCount100Km": "value",
"dealerCount150Km": "value",
"test": "value"
}
}

Display Information​

  • In the sidebar, switch to the
    Loading...
    .
  • Switch to the layout editor by clicking the pencil icon next to the Mobile/Desktop selector at the top.
  • If you haven’t already, click
    Loading...
    .

Now you can insert a component of the type

<CustomData path="pfad.im.json"/>

—for example:

<CustomData path="shippingPrice" />

into the layout. The text from the selected location in the JSON document will then be displayed at this point.

If the value is a number, add type="html": <CustomData path="shippingPrice" type="html" />. The value 0 and empty text are not displayed.

If nothing appears, add silentErrors="false" to test it. The component will then display whatever it finds in the JSON.