Macro doesn't work...

Martin Doré asked on March 15, 2017 18:35

I'm a newcomer in Kentico.

I tried to use the "CurrentDevice" from a macro to call an image server with the right values for the width and height (optimization purpose).

I put in one of my page a static Html widget and I put this content : {% CurrentDevice.ScreenPixelsHeight @%} {% CurrentDevice.ScreenPixelsHeight #%}

I read the documentation about macros and I can't figured what is going on. I enabled the debugging but it seems that the K# is never triggered for this macro... I also tried with other variables without success (not just only device).

It always displayed the string without transformation in the page.

Maybe I forgot something or I did something wrong.

Someone could point me what I'm doing wrong?

Thanks in advance

Recent Answers


Jim Spillane answered on March 15, 2017 19:00

Hi Martin.

I believe that the ScreenPixelsHeight & ScreenPixelsWidth properties are not available in the lite version that comes with Kentico. Are you subscribed to the 51degrees.mobi Premium data?
Reference - device macros

1 votesVote for this answer Mark as a Correct answer

Martin Doré answered on March 15, 2017 21:36

Not yet! Maybe, we will purchase it. I think it's the best option so far.

But we also need a backup plan to mitigate risk if 51degrees decides in the future to not provide the data anymore.

I also need to do a proof of concept to convince my boss to pay for this feature...

Do you know how I can do that?

The documentation is not really clear on this subject. 1) What properties are availables when we disabled 51Degrees with this entry in the web.config ? 2) What properties are available whit the 51Degrees lite version?

I know I could read the user agent from javascript and retrieve some information from this field. But it is not very reliable!

Thanks again for your time!

0 votesVote for this answer Mark as a Correct answer

Jim Spillane answered on March 16, 2017 18:36

Chrome DevTools will allow you to change the User-Agent string to test differnt devices.

The lite version of 51Degrees is included with Kentico. If you need to use properites from newer devices, the premium version is updated more frequently.

From the 51Degrees Device Data FAQ, the Lite data contains the four following properties:

  • IsMobile
  • LayoutEngine
  • ScreenPixelsHeight
  • ScreenPixelsWidth
0 votesVote for this answer Mark as a Correct answer

Martin Doré answered on March 17, 2017 16:31 (last edited on December 10, 2019 02:30)

Thanks for the information! But the macro still doesn't appear (the transformation never occurs).

I put this in a staic html widget : {% CurrentDevice.ScreenPixelsHeight @%} and the result is {% CurrentDevice.ScreenPixelsHeight @%} {% CurrentDevice.ScreenPixelsHeight |(identity)GlobalAdministrator%}

Honestly, I don't think it's related to the device...

0 votesVote for this answer Mark as a Correct answer

Jim Spillane answered on March 17, 2017 17:34 (last edited on December 10, 2019 02:30)

Check to see if Configuring mobile development is enabled.

When I use this in a webpart:

<p>
  [CurrentDevice.ScreenPixelsHeight] [{% CurrentDevice.ScreenPixelsHeight |(identity)GlobalAdministrator%}] <br>
</p>

I get this for an iPhone 5...

Image Text

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.