defining "variables" in TypoScript


Designing a template you don't want to use always the same repeating strings. Variables allow to reuse strings in your code and thus make it easier to adapt
your template for other projects.

Example: You want to provide a string with your address to use it somewhere in the site.

Define the constants:

  1. ###############
  2. ### CONSTANTS ###
  3. ###############
  4.  
  5. myaddress{
  6.   name= Luigi
  7.   url = http://www.snippit.net
  8.   address {
  9.     street= Via www
  10.     number= 9
  11. }

Now you can reuse it anywhere in your setup code:

  1. ###############
  2. ##### SETUP #####
  3. ###############
  4.  
  5. page = PAGE
  6. page.typeNum=0
  7.  
  8. page.10 = TEXT
  9. page.10.value = My name is {$myaddress.name}
  10. page.10.wrap=|<br>
  11.  
  12. page.20 = TEXT
  13. page.20.value = I live in {$myaddress.address.street} {$myaddress.address.number}
  14. page.20.wrap=|<br>
  15.  
  16. page.30 = TEXT
  17. page.30.value = Visit my homepage
  18. page.30.wrap=<a href="{$myaddress.url}">|</a>
  19.  
  20. #etc.etc.
  21.  
Last update: 10.04.2006

Did this document help you?

Yes: Write us what helped you

Ok, but: Suggest improvements, report inaccuracies etc.

not helpful: Tell us what would have helped