Configurator & presets variable
Everything you create in the configurator editor is either directly or indirectly connected to your configurator. With the configurator variable you can access all these things and additional information about your configurator.
|isDraft||will be true inside a draft and false in a published configurator|
|startUrl||the URL for starting a new configuration based on the default preset|
|components||a map of all the components you have created|
You can access these properties like so: configurator.IsDraft
In addition to the properties above, you can also access any of your components with the configurator variable. For example, configurator.Price would refer to a "price" component. Of course, you can also just write price to work with that component – usually.
You may end up in a situation where something else is also called "price" and simply writing price will return that thing. This can happen for example in a graphic component, when you give one of your visuals the name "price". Inside that component, "price" will then refer to your visual and not the price component. To fix that problem, you can write configurator. Price to get to your component.
The best way to avoid this problem is not to call anything "configurator" – but in case you have to, there's a special keyword to help you out: @top. This rarely used keyword is always reachable and enables you to access things "at the top", like the configurator variable. For example, @top.configurator.Price will always refer to the "price" component, no matter what.
You can work with the presets that you have created for your configurator by using the presets variable. Similar to configurator, you can access any preset by name by writing presets.MyPreset (where "MyPreset" is the name you've given your preset). However, in this case the presets variable is mandatory – "MyPreset" alone will not return your preset.
Additionally, the presets variable has these built-in properties:
|current||returns the preset on which the current configuration is based|
|default||returns the default preset of your configurator|
|all||returns a map of all the presets you have created|
Once you have obtained a preset, you can use its properties:
|id||the unique identifier of this preset|
|startUrl||the URL for starting a brand-new configuration based on this preset|
To get the URL to start a new configuration based on the same preset as the current configuration: