Posted on 28/04/2014 15:53:18
In Razor templates you should rarely use global tags, but instead use the API objects available, e.g.
@if (Pageview.Device == Dynamicweb.Frontend.PageView.DeviceType.Mobile) {
<div>Mobile</div>
} else if (Pageview.Device == Dynamicweb.Frontend.PageView.DeviceType.Tablet) {
<div>Tablet</div>
} else {
<div>Desktop</div>
}
If really you want to get a global tag in Razor, you have to use @GetGlobalValue, e.g.
@GetGlobalValue("Global:Device.IsDesktop")
@GetGlobalValue("Global:Device.IsTablet")
@GetGlobalValue("Global:Device.IsMobile")
and these work fine (for me at least).
See the section Global tags in Razor templates [http://developer.dynamicweb-cms.com/Admin/Public/DWSDownload.aspx?File=Files%2fFiler%2fDocumentation%2fDesign%2f(en-US)+Razor+templates.pdf] for details.
I have no problems using device layouts with Razor templates, and the device layouts are handles long before Razor actually processes the templates.
If it does not work for you, then please report back what version of Dynamicweb you are running and also the user agent strings of the devices you use for testing (use http://user-agents.me/whats-my-user-agent or similar tools to get the user agent string).
Best regards,
Mikkel