Site rendering modes¶
Go Mobile defines different rendering modes, which defines which theme is chosen, what templates are used, how template is rendered what and what content is included in the output.
Usually rendering mode is decided by domain name. Ff domain name starts with m. or ends with .mobi it is rendered in the mobile mode.
Note that these different
- Rendering mode
- Current browser user agent
Web site can be also rendered for mobile handsets and vice versa.
- web: Site is rendered in web site mode. Display content marked for web viewing.
- mobile: Site is rendered in mobile site mode. Display content marked for mobile viewing.
- admin: Site is rendered in web site mode. Display content marked for both for web and mobile viewing.
from zope.component import getUtility from gomobile.mobile.interfaces import IMobileRequestDiscriminator, MobileRequestType discriminator = getUtility(IMobileRequestDiscriminator) flags = discriminator.discriminate(self.context, self.request) if MobileRequestType.MOBILE in flags: # Do things necessary for mobile sie pass elif MobileRequestType.ADMIN in flags: # The site is rendered in web mode, # but if there are special content items # which are displayed to the site visitors # only in mobile mode, display them also now. # You don't usually need to do this. pass elif MobileRequestType.PREVIEW in flags: # Site is rendered in IFRAME simulator # You don't usually need to handle this # Use MobileRequestType.MOBILE only. pass else: # Do things necessary for web site pass