TypoScript Syntax

NOT RENDERED: OFFICE:FORMS

TypoScript Syntax and In-depth Study
Note about perceived semantics: Note about the internal structure when parsed into a PHP array:     $TS['asdf.']['zxcvbnm'] = 'uiop';     $TS['asdf.']['backgroundColor'] = 'blue';     $TS['asdf.']['backgroundColor.']['transparency'] = '95%'; $TS = array(     'asdf.' => array(         'zxcvbnm' => 'uiop',         'backgroundColor' => 'blue',         'backgroundColor.' => array (             'transparency' => '95%'         )     ) ) We might even call 'myProperty' for a TypoScript object in this example! This is already explained in the introduction chapter. Example:
Example: // This is a comment / This is also a comment (only ONE slash is needed) # This line is also a comment. Rules:
Example: /* This is a comment  .. and this line is within that comment which...   ends here: */  ... this is not parsed either though - the whole line is still within the comment   Here's a multiline value which   /*     ignores comments in side, so this is parsed!   */ ) Value assignment: The "="-operator Rules:
Value modifications: The ":="-operator Rules:
Example:     Example: } Rules:
  1. NOTE: Excessive endbraces are ignored, but issues a warning in the TypoScript parser.
Example:   <BLINK>     HTML - code     </BLINK> ) Rules:
Example:
Another example (copy from within curly brace confinement): } }   Note about references to objects (in TypoScript Templates): Example: [browser=netscape] [else] [end] Rules:
[ condition 1 ][ condition 2] [GLOBAL] [browser = netscape][system = WinNT] } [GLOBAL]   There's a special condition called [ELSE] which will return true if the previous condition returned false. To end an [ELSE] condition you can use either [END] or [GLOBAL]. For all three conditions you can also use them in lower case. [browser=netscape] [else] [end] [browser=netscape][usergroup=3]   # Enter nothing here! [else] [end]
XML and TypoScript - all about syntax: XSLT and "TypoScript Templates" - all about semantics (meaning, function):
}
}
   3: require_once(PATH_t3lib.'class.t3lib_tsparser.php');    4:    5: $TSparserObject t3lib_div::makeInstance('t3lib_tsparser');    6: $TSparserObject->parse($tsString);    7:    8: echo '<pre>';    9: print_r($TSparserObject->setup);   10: echo '</pre>';
echo '<table bgcolor="'.$TSparserObject->setup['colors.']['backgroundColor'].'">     <tr>         <td>             <font color="'.$TSparserObject->setup['colors.']['fontColor'].'">HELLO WORLD!</font>         </td>     </tr> </table>';    1: require_once(PATH_t3lib.'class.t3lib_tsparser.php');    2:    3: class myConditions {    4:     function match($conditionLine)    {    5:         if ($conditionLine == '[TYPO3 IS GREAT]')    return true    6:     }    7: }    8: $matchObj t3lib_div::makeInstance('myConditions');    9:   10: $TSparserObject t3lib_div::makeInstance('t3lib_tsparser');   11: $TSparserObject->parse($tsString$matchObj);   12:   13: debug($TSparserObject->setup);  
   1: class myConditions {    2:     function match($conditionLine)    {    3:             // Getting the value inside of the square brackets:    4:         $insideSqrBrackets trim(ereg_replace('\]$','',substr($conditionLine,1)));    5:             6:             // Splitting value into a key and value based on the "=" sign    7:         list($key,$value) = explode('=',$insideSqrBrackets,2);    8:             9:         switch(trim($key))    {   10:             case 'UserIpRange':   11:                 return t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), trim($value)) ? TRUE FALSE;   12:             break;   13:             case 'Browser':   14:                 return $GLOBALS['CLIENT']['BROWSER']==trim($value);   15:             break;   16:         }   17:     }   18: }
[browser = netscape][browser = opera] [GLOBAL] [ CON 1 ] && [ CON 2 ] || [ CON 3 ]    1: class myConditions {    2:         3:     /**    4:      * Splits the input condition line into AND and OR parts    5:      * which are separately evaluated and logically combined to the final output.    6:      */    7:     function match($conditionLine)    {    8:             // Getting the value from inside of the wrapping    9:             // square brackets of the condition line:   10:         $insideSqrBrackets trim(ereg_replace('\]$','',substr($conditionLine,1)));   11:            12:             // The "weak" operator, OR, takes precedence:   13:         $ORparts split('\][[:space:]]*\|\|[[:space:]]*\[',$insideSqrBrackets);   14:         foreach($ORparts as $andString)    {   15:             $resBool FALSE;   16:                    17:                 // Splits by the "&&" and operator:   18:             $ANDparts split('\][[:space:]]*\&\&[[:space:]]*\[',$andString);   19:             foreach($ANDparts as $condStr)    {   20:                 $resBool $this->evalConditionStr($condStr) ? TRUE FALSE;   21:                 if (!$resBool)    break;   22:             }   23:                24:             if ($resBool)    break;   25:         }   26:         return $resBool;   27:     }   28:        29:     /**   30:      * Evaluates the inner part of the conditions.   31:      */   32:     function evalConditionStr($condStr)    {   33:             // Splitting value into a key and value based on the "=" sign   34:         list($key,$value) = explode('=',$condStr,2);   35:            36:         switch(trim($key))    {   37:             case 'UserIpRange':   38:                 return t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), trim($value)) ? TRUE FALSE;   39:             break;   40:             case 'Browser':   41:                 return $GLOBALS['CLIENT']['BROWSER']==trim($value);   42:             break;   43:         }   44:     }   45: }    1:     /**    2:      * Splits the input condition line into AND and OR parts    3:      * which are separately evaluated and logically combined to the final output.    4:      */    5:     function match($conditionLine)    {    6:             // Getting the value from inside of the wrapping    7:             // square brackets of the condition line:    8:         $insideSqrBrackets trim(ereg_replace('\]$','',substr($conditionLine,1)));    9:            10:             // The "weak" operator, OR, takes precedence:   11:         $ORparts split('\][[:space:]]*\|\|[[:space:]]*\[',$insideSqrBrackets);   12:         foreach($ORparts as $andString)    {   13:             $resBool FALSE;   14:                    15:                 // Splits by the "&&" and operator:   16:             $ANDparts split('\][[:space:]]*\&\&[[:space:]]*\[',$andString);   17:             foreach($ANDparts as $subOrStr)    {   18:                19:                     // Split by no operator between ] and [ (sub-OR)   20:                 $subORparts split('\][[:space:]]*\[',$subOrStr);   21:                 $resBool FALSE;   22:                 foreach($subORparts as $condStr)    {   23:                     if ($this->evalConditionStr($condStr))    {   24:                         $resBool TRUE;   25:                         break;   26:                     }   27:                 }               28:   29:                 if (!$resBool)    break;   30:             }   31:                32:             if ($resBool)    break;   33:         }   34:         return $resBool; #1: Line syntax: (Notice: Between COND3 and COND4 the blank space is implicitly an OR)   #2: Subpart syntax: For each subpart (for example "[ COND 1 ]") the content is evaluated as follows:     [ KEY = VALUE ]   where KEY denotes a type of condition from the table below:
   

To top


Valid XHTML 1.0!