TSRef - TypoScript Reference

4.1.21. globalString:

Syntax:

  [globalString =   var1=value,  var2= *value2, var3= *value3*, ...]

 

Comparison:

This is a direct match on global strings.

You have the options of putting a "*" as a wildcard or using a PCRE style regular expression (must be wrapped in "/") to the value.

Examples:

If the HTTP_HOST is "www.typo3.com" this will match with:

      [globalString = HTTP_HOST=www.typo3.com]

 

This will also match with it:

      [globalString = HTTP_HOST= *typo3.com]

 

... but this will also match with a HTTP_HOST like this: "demo.typo3.com"

 

IMPORTANT NOTE ON globalVar and globalString:

You can use values from global arrays and objects by deviding the var-name with a "|" (vertical line).

Examples:  The global var $HTTP_POST_VARS["key"]["levels"] would be retrieved by "HTTP_POST_VARS|key|levels"

Also note that it's recommended to program your scripts in compliance with the php.ini-optimized settings. Please see that file (from your distribution) for details.

Caring about this means that you would get values like HTTP_HOST by getenv(), you would retrieve GET/POST values with t3lib_div::GPvar(). Finally a lot of values from the TSFE object are useful. In order to get those values for comparison with "globalVar" and "globalString" conditions, you prefix that varname with either "IENV"/"ENV:" , "GP:",  "TSFE:" or "LIT:" respectively. Still the "|" divider may be used to separate keys in arrays and/or objects. "LIT" means "literal" and the string after ":" is trimmed and returned as the value (without being divided by "|" or anything)

Notice: Using the "IENV:" prefix is highly recommended to get server/environment variables which are system independant. Basically this will call and return the value from t3lib_div::getIndpEnv() function. With "ENV:" you get the raw output from getenv() which is NOT always the same on all systems!

Examples:

This will match with a url like "...&print=1"

      [globalVar = GP:print > 0]

 

This will match with a remote-addr begining with "192.168."

      [globalString = IENV:REMOTE_ADDR = 192.168.*]

 

This will match with the page-id being higher than 10:

      [globalVar = TSFE:id > 10]

 

This will match with the pages having the layout field set to "Layout 1":

      [globalVar = TSFE:page|layout = 1]

 

This will match with the user whose username is "test":

      [globalString = TSFE:fe_user|user|username = test]

 

If the constant {$constant_to_turnSomethingOn} is "1" then this matches:

      [globalVar = LIT:1 = {$constant_to_turnSomethingOn}]

 


Valid XHTML 1.0!