Setting a GET Parameter as a Variable in Typoscript

Written by Zac Vineyard

typo3_corn_pick.jpgRecently I had a problem that, in spite of many "support leads" on other sites, was hard to figure out. All I wanted to do was reference as GET parameter in a URL as a variable in Typoscript. After many failed attempts, I found a solution to my problem. So, for future reference, and for all others who may be struggling with this problem, below is a slice of example code that solved my problem.

One thing to note: you must "type-cast" your Typoscript variables by defining their type. That's what you see happening in the first part of the following code example:

What I was trying to accomplish was changing news categories on a single page so that different news would display on a page simply by changing a category number. The two lines you should pay attention to above are:
categorySelection = TEXT
categorySelection.data = GPvar : cat
Here, the code "GPvar : cat" will get the value of a GET parameter named "cat" out of a URL like this:
http://www.example.com/index.php?id=7565&cat=19
What I discovered was that, in order to use the GET parameter in Typoscript, I needed to type the variable in Typoscript before it could be referenced. Hence the "categorySelection = TEXT" code.