Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (51 sloc) 2.32 KB
============================
Site rendering modes
============================
.. admonition:: Description
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.
.. contents :: :local:
Introduction
------------
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.
Modes
-----
* 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.
* preview: Site is rendered in mobile site mode. Display content marked for mobile viewing. Special IFRAME javascript
code is used to bootstrap mobile site simulator.
Determining the mode
--------------------
Example
.. code-block:: python
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
See also
--------
* gomobile.mobile.interfaces.IMobileRequestDiscriminator
You can’t perform that action at this time.