Setting a GET Parameter as a Variable in Typoscript
Recently 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:
Here, the code "categorySelection = TEXT categorySelection.data = GPvar : cat
GPvar : cat" will get the value of a GET parameter named "cat" out of a URL like this:
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 "http://www.example.com/index.php?id=7565&cat=19
categorySelection = TEXT" code.