问题
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?
回答1:
You should check a few things:
- The setting may be case-sensitive, try capitalizing Mobile in the device attribute
- Ensure the device is published
- Ensure when you hit the URL, that you are getting the correct site -- try outputting Sitecore.Context.Site.Name or use a tool like Glimpse to debug. If you're not, make sure you have an exact host name match and that the mobile site appears first in your sites list.
- Perhaps try the defaultDevice attribute instead of the device attribute on the site
回答2:
I guess you should add a hostName to the "website" site as well. And the device is proably case sensitive.
You can also extend the Sitecore httpRequestBegin pipeline to identify whch device to use based on the browser's USER_AGENT string, and switch device within the same site context.
See here how to to it: http://briancaos.wordpress.com/2012/04/12/identifying-mobile-devices-in-sitecore/
来源:https://stackoverflow.com/questions/10653783/sitecore-mobile-detection