Device macros

CurrentDevice

The CurrentDevice object holds information about the device detected for the current visitor. The system identifies devices based on their user agent and retrieves the data about the capabilities of devices from the integrated 3rd party component 51degrees.mobi or the ~\App_Data\CMSModules\DeviceProfile\devices.xml file.

You can take advantage of the CurrentDevice object when defining conditions for device profiles and in general macro expressions. You can see a full list of device properties on the 51Degrees website.

Most of the properties are accessible through the Data container. For example:

  •  {% CurrentDevice.Data["Javascript"] %}

Some of the properties are accessible directly:

  • {% CurrentDevice.IsMobile %}

Note that most of the properties are only available when using the 51degrees.mobi On-Premise Premium Data license. By default, Kentico includes the Lite license which you can upgrade.

CurrentDeviceProfile

To get information about the device profile assigned to the current visitor, use the CurrentDeviceProfile object in macros:

  • You can access the device profile's system data through its properties, for example: {% CurrentDeviceProfile.ProfilePreviewWidth %}
  • To directly get the device profile's name, use the following expression: {% CurrentDeviceProfileName %}


Was this page helpful?