It is possible to define dedicated templates for specific user agents. If the system finds the request is coming from a configured user agent, it can append a specific classifier to the template type, and will then look the template in another folder.
The mapping between user agent and template types is done in the applicationContext-services.xml file, under the UserAgentFilter bean configuration :
<bean class="org.jahia.services.channels.filters.ChannelResolutionFilter" > <property name="priority" value="4" /> <property name="applyOnModes" value="live,preview" /> <property name="userAgentMatchingRules"> <map> <entry key=".*iPhone.*" value="iphone" /> <entry key=".*iPod.*" value="iphone" /> </map> </property> </bean>
The userAgentMatchingRules attribute defines a list of regular expression and the associated template type extension. Here, all user agents matching .*iPhone.* and .*iPod.* will have an iphone template type classifier.
When using the previous configuration, for any request coming from an iPhone, the system will try to find templates for iphone. If an standard .html request was done, it will first lookup the template into the html-iphone folder, and will then fallback on the standard html folder if the template is not available. This is done for every node and wrapper included in the page : a page can mix user-agent specific and generic templates.