2

I cant seem to get mobile detection working. I added the following "mobile" web.config changes:

<site name="mobile" hostName="m.localhost" device="mobile" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />

<site name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" /> 

I also added a new device called "Mobile" to the device list. From what I understand if someone visits m.localhost (dev URL, yes I know) no matter the device I would expect it to use the "Mobile" device presentation. It's not, its using the standard one. If I specify sc_device=mobile it does load the "Mobile" device layout. Any thoughts?

4

2 回答 2

2

你应该检查几件事:

  • 该设置可能区分大小写,请尝试在设备属性中将 Mobile 大写
  • 确保设备已发布
  • 确保在点击 URL 时获得正确的站点——尝试输出 Sitecore.Context.Site.Name 或使用Glimpse之类的工具进行调试。如果不是,请确保您的主机名完全匹配,并且移动网站首先出现在您的网站列表中。
  • 也许尝试使用 defaultDevice 属性而不是站点上的 device 属性
于 2012-05-18T14:36:32.343 回答
1

我想您也应该在“网站”站点中添加一个主机名。并且该设备可能区分大小写。

您还可以扩展 Sitecore httpRequestBegin 管道,以根据浏览器的 USER_AGENT 字符串识别要使用的设备,并在同一站点上下文中切换设备。

请参阅此处如何操作:http: //briancaos.wordpress.com/2012/04/12/identifying-mobile-devices-in-sitecore/

于 2012-05-25T09:08:56.453 回答