+

Search Tips   |   Advanced Search

Device class support in a migrated theme

The new device and device equation classes support modifications to the themes from previous versions so they are more efficient. We can remove or modify certain aspects of a prior theme that we migrated. These changes are optional.

This version of Portal v8.5 supports ios, android, blackberry, and worklight in addition to the smartphone and tablet themes it already supports. We can also use equation support to combine individual device classes to check for multiple client conditions. For example, if you were manually integrating with Worklight in a previous version, and manually created some combination device classes, such as smartphone-ios, tablet-ios, smartphone-android, tablet-android, the combination device classes are no longer needed. The individual device classes can be combined in equations, such as smartphone+ios, tablet+ios. If we had a combination device class such as hires-tablet-ios, we can change to define the singular hires device class. Then, use equations to combine with the other default singular device classes, such as hires+tablet+ios. In these equations, use + for AND, / for OR, ! for NOT and parentheses to group items together. See Device Class Equations.

In the .jsp logic, for example, we can change the previous version syntax with <c:if> against deviceClass. Here is an example of code from a previous version:

    <c:set var="deviceClass" scope="request" value="${wp.clientProfile['DeviceClass']}" />
    <c:set var="isMobile" scope="request" value="${deviceClass == 'tablet' || deviceClass == 'smartphone'}" />
    <c:if test="${isMobile}">
    ...
    </c:if>

We can change that to a new equation syntax with <portal-logic:if> with the new deviceClass parameter. For example:

We can now use device class equations in module subcontributions in theme contributions .json files. For example:

    }, {
    "value":"/css/my_css_smartphone_ios.css", "type":"smartphone+ios"
    }, {

Dynamic content spots in theme templates can now also be varied entirely with device class equations. For example:

    mvc:res:/hello.jsp,smartphone+ios@res:/hello_smartphone_ios.jsp,(smartphone/tablet)+android@res:/hello_mobile_android.jsp

In this example, use res:/hello.jsp as the default URI, res:/hello_smartphone_ios.jsp as the URI for iOS smartphones, and res:/hello_mobile_android.jsp as the URI for Android smartphones and tablets.


Parent Enable new functionality in a migrated portal