V13 Macro for IsMobleDevice not found.

Daniel Main asked on January 5, 2023 20:34

in Kentico V12 we were using {% !CurrentDevice.Data["IsMobileDevice"] #%} to be able to switch the menus depending if the device was mobile or not, now we are updating to V13 and I am finding that macro is non-exsistant.

Is there a way to accomplish this in the new Kentico system?

Correct Answer

Brenden Kehren answered on January 5, 2023 20:58

Macros are not available on the public facing .NET 6/Core site. You'll have to use other means to detect this. I'd suggest using javascript or css to determine the viewport size and what's visible or not.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Daniel Main answered on January 5, 2023 22:20

Ok, thanks, I was afraid of that, what was the reason for removing macros though.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 5, 2023 22:22

Macros are still available, but they cannot be processed on the MVC side of things because its outside the context of the CMS now. Before it was all part of the same and now it's different.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 6, 2023 08:28

To add to what Brended said - in the MVC development model was the content management part and web site presenation part separated. You need to keep in mind that you have two separate apps; admin app vs. front end app and they each have their own, separate context available. That being said, in your front end app you can use standard MVC5 features to detect devices. You do not need to rely on Kentico macros or API that much anymore when it comes to some general things like this one.

0 votesVote for this answer Mark as a Correct answer

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