[All Adaptavist Apps]

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
Display content based on UserAgent
Display content based on UserAgent

You can use the useragent parameter to check for certain sub-strings such as browser names and operating systems in the user agent string provided by browsers that visit your site. This could be used to tailor content to specific devices such as mobile phones.
Notice in the following code that you can provide a comma separated list of token tokens to be tested for, this . This acts like an OR so , if any of the tokens match then the enclosed code will be rendered.

Code Block
{builder-show:useragent=Firefox,Opera}
You are using FireFox or Opera!
{builder-show}

By combining with the use-layout macro you can switch to a specific layout.
For example suppose you have created a layout for iphonethe iPhone.
Do on the following on your home page and subsequent page will use your layout:

Code Block
{builder-show:useragent=iphone}
{use-layout:IPHONE_LAYOUT|latch=true}
{builder-show}

...