How to use "For" tags

Revision Information
  • Revision id: 15326
  • Created:
  • Creator: Michael Verdi
  • Comment: Updated for recent changes to {for}
  • Reviewed: No
  • Ready for localization: No
Revision Source
Revision Content

One of the great features of our Knowledge Base is the ability to show instructions customized for operating systems and Firefox versions. We can say, for example, that a certain section of a help article is "for" Windows users and Mac and Linux users won't see it. The feature is designed to work invisibly. When someone opens a help article, we'll automatically detect what operating system and version of Firefox they are using and show the appropriate instructions. This article goes over the details of how to use {for} in Knowledge Base articles.

Basic syntax and behavior

Operating Systems

Here is the syntax to show something for Windows only:

{for win}Hellooo!{/for}

  • Change the "Help with:" selector to Windows to see a message => Hellooo!
  • If you change the "Help with:" selector to Mac OS X or Linux the message above will disappear because it's not "for" them.
Note: If you change the "Help with:" selector to Android or Mameo the message is visible even though they aren't specified. That's because we default to showing Windows instructions (unless otherwise specified) if you are using Firefox on mobile. We also default to showing Android instructions if you are looking at Mobile article with Windows, Mac or Linux.


Firefox versions

Here is the syntax to show something for Firefox 4 and above:

{for fx4}Hellooo!{/for}
  • Change the "Help with:" selector to Firefox 4 or 5 to see a message => Hellooo!
  • If you change the "Help with:" selector to Firefox 3.5 - 3.6 the message above will disappear because it's not "for" them.


Here is the syntax to show something for Firefox 5 and above:

{for fx5}Hellooo!{/for}
  • Change the "Help with:" selector to Firefox 5 to see a message => Hellooo!


Show instructions for only one version of Firefox

To show instructions only for Firefox 4, use the "=" operator:

{for =fx4}Hellooo!{/for}
  • Now the message only shows when you change the "Help with:" selector to Firefox 4 => Hellooo!


Firefox 3.5-3.6 work differently. When you specify {for fx35} the instructions will show up only for Firefox 3.5-3.6:

{for fx35}Hellooo!{/for}
  • Change the "Help with:" selector to Firefox 3.5-3.6 to see a message => Hellooo!


Operating systems & Firefox versions

You can specify an operating system and a Firefox version by separating them with a comma:

{for mac,fx4}Hellooo!{/for}

  • Change the "Help with:" selector to Mac and Firefox 4 or Firefox 5 to see a message => Hellooo!


A more complex condition with an implied "or" can be written like this:
{for mac, win, fx35, =fx4}You are running Mac or Windows and using Firefox 3.5-3.6 or 4.{/for}

  • Change the "Help with:" selector to Mac or Windows and Firefox 3.5-3.6 or Firefox4 to see a message =>You are running Mac or Windows and using Firefox 3.5-3.6 or 4.


Formally, the markup between {for} and {/for} will be shown if either of these conditions is met:

  • The {for} lists at least one OS and includes the one the user is running (or has manually selected).
  • The {for} lists at least one Firefox version and includes the one the user is running (or has manually selected).

Otherwise, the contents of the {for}...{/for} is not shown.

A few other things to note:

  • Spaces after the commas are optional.
  • The {for} syntax is always enabled.
  • Headings which are hidden by {for} blocks do not appear in the page's table of contents. If the user causes them to show by manually selecting the right OS/browser combination, the table of contents entries instantly appear.


Operating system and browser abbreviations

These are the operating system and browser abbreviations available for use with {for}:

  • win (Windows)
  • mac (Mac OS X)
  • linux (Linux)
  • maemo (Maemo mobile OS)
  • android (Android mobile OS)
  • fx35 (Firefox 3.5 up to but not including 4)
  • fx4 (Firefox 4.0 and up)
  • fx5 (Firefox 5.0 and up)
  • fx6 (Firefox 6.0 and up)
  • m4 (Firefox 4 for mobile and up)
  • m5 (Firefox 5 for mobile and up)
  • m6 (Firefox 6 for mobile and up)
Note: We'll add new Firefox versions as needed (i.e. fx7)


Inline and block-level contexts

{for} can be used in both inline and block-level contexts (in the HTML sense). The inline form takes effect when working within a line of text:

This is {for fx35, fx4}inline use{/for}.

The block form is used to wrap entire paragraphs, ordered lists, headings, and so on. The only caveat is that, when using the block form, the {for} and {/for} should each be on a line by itself. Otherwise, it might be considered part of a neighboring paragraph and produce surprising results.

{for fx35, fx4}
This is block-level.
*One
*Two
{/for}


Using the handy dandy {for} button in the article editor

When you're editing a Knowledge Base article you can use the {for} button in the toolbar to write the markup for you.

  1. Highlight the text you want to put {for} tags around.
  2. Click Show for... in the editing toolbar.
  3. Check the boxes next to the Firefox versions and operating systems that you want to see this piece of content and then click Add Rule. The customized {for} tags will be placed around the section you highlighted.


Best practices for using {for} in articles

When writing instructions for different operating systems, it's best to write complete sentences and paragraphs for each OS/Firefox version even if it means duplicating things. This makes the article easier to understand, maintain and localize. When it comes time, for example, to remove Firefox 3.5/3.6 specific instructions, those sections can just be deleted rather than trying to excise them from a larger section.

Example:
Bad
#{for win,linux}At the top of the Firefox window{/for}{for mac}On the menu bar{/for}, click on the {for fx35}{menu Tools}{/for}{for mac,linux,fx4}{menu Tools}{for win,fx4}{menu Firefox} menu, go over to the {menu History} menu and select {menu Clear Recent History...}{/for}{for not win,fx4} menu, and select {/for}{for win,fx35}{menu Clear Recent History...}{/for}{for mac,linux}{menu Clear Recent History...}{/for} {for win,fx4}<br>'''For Windows XP:''' At the top of the Firefox window, click on the {menu Tools} menu and select {menu Clear Recent History...}{/for}

Good
{for fx4}
#{for win}At the top of the Firefox window, click on the {menu Firefox} menu, go over to the {menu History} menu and select {menu Clear Recent History...} ('''Windows XP:''' Click on the {menu Tools} menu and select {menu Clear Recent History...}).{/for}{for mac}On the menu bar, click on the {menu Tools} menu and select {menu Clear Recent History...}{/for}{for linux}At the top of the Firefox window, click on the {menu Tools} menu and select {menu Clear Recent History...}{/for}
{/for}
{for fx35}
#{for win,linux}At the top of the Firefox window, click on the {menu Tools} menu and select {menu Clear Recent History...}{/for}{for mac}On the menu bar, click on the {menu Tools} menu and select {menu Clear Recent History...}{/for}
{/for}