- Print
- DarkLight
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.
Properties
name | description |
isDraft | will be true inside a draft preview and false in a published or staged configurator or preview thereof |
isPreview | true in a configurator preview, false anywhere else |
isStaging | true in a staged configurator, false anywhere else |
isPublished | true in a published configurator, false anywhere else |
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.isPublished
Accessing components
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.
Presets
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:
name | description |
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:
name | description |
id | the unique identifier of this preset |
startUrl | the URL for starting a brand-new configuration based on this preset |
Example
To get the URL to start a new configuration based on the same preset as the current configuration:
presets.Current.StartUrl