Cast Iron Coding, LLC
TypoScript Techniques

Understanding optionSplit

By: Lucas Thurston


The | in the expression is the HTML character code for the horizonal line, spelled out so we don't interfere with stdWrap or optionSplit. Without the subparts divider in action, the rules for the FML divider can be summarized like this:

  1. Priority is last, first, middle.
  2. Middle will repeat as necessary.
  3. If the middle value is empty, the first value will repeat until the last value. Since one of the goal listed above was to define the limits of optionSplit we could add this rule as well:
  4. If the first and middle values are empty, the last value will repeat. Or, more generally:
  5. If any two of the first, middle or last parts (remember, only as differentiated by the FML divider) are empty in an optionSplit statement, the place-value that is not empty will be repeated. As we know, however, we could just repeat by leaving all dividers out, so this rule is not going to be applied very often.

The subparts divider ( || ) does not always behave the same way. Its behavior varies with the context in which it occurs. By context, in this case, we are referring to how the where in the expression it occurs in relation to the maximum of two FML dividers. In the first and middle part or context (with or without any FML dividers in the expression), the each value is activated in a first-come, first-served manner. This means that:

first || second ||third || fourth

with a 3-page menu will render: first, second, third. With a 5-page menu, however, the last value will repeat: first, second, third, fourth, fourth. In the same shorthand we used above we could describe this type of menu like this:

x1||x2||x3...||xn produces x1,x2,x3,...xn*

In the "last" context, like this:

|*||*|first||second||third||fourth

the tables turn, however. Suddenly we have a last-come, first-served situation where the first value repeats. What you see directly above with a 3-page menu will produce: second, third, fourth. With a 5-page menu we get: first, first, second, third, fourth. We'll describe this menu like this in shorthand:

|*||*|x1||x2||x3||...xn produces x1*,x2,...xn

Posted on Friday, August 26, 2005 at 01:54 PM.