Add parameter to link in typoscript

ak85 picture ak85 · Aug 12, 2012 · Viewed 11.7k times · Source

I have my site setup so that if you are on a mobile you get a mobile rendered template. To click to go to the main site you go

index.php?id=??&mainsite=1

This all works fine however I have a link at the bottom of my mobile template that says go to main site. I want this to go to the main template page for the current page id eg

index.php?id=page:uid&mainsite=1

If I do

lib.mainsitelink= TEXT
lib.mainsitelink.data = page:uid

I get

www.example.com/uid

so when uid = 3 i get

www.example.com/3

but if i do the below code it doesn't work

lib.mainsitelink= TEXT
lib.mainsitelink.data = index.php?id=page:uid&mainsite=1

Is there a way to either do what I am trying to do or add a parameter to the end of the current url? eg what I am trying to do won't quite work on the news single page.

Answer

Gigamegs picture Gigamegs · Aug 12, 2012

First off, I don't think that the cobj text has a method data hence I would change that to the value method. Also when you want to use the getText data type you need to warp the variables with curly braces and then add the method insertData = 1 to it so everything inside the curly braces get replaced. Here is a complete example: http://wiki.typo3.org/TSref/getText. Of course you can use a typolink cobject to replace the page id. Second you can add an additional link parameter (i.e. get-parameters) with the additionalParams method (with a typolink of course) or you can use a plain cobj text. Here is an example with a cObj image and stdWrap cObj typolink and tt_news get-parameters. It also opens a popup-window.

             40=IMAGE
             40.file=print.gif                 
             40.stdWrap.wrap = <div>|</div>
             40.stdWrap.typolink.no_cache = 1 
             40.stdWrap.typolink.parameter.data = page:uid
             40.stdWrap.typolink.parameter.wrap = | ,1 print
             40.stdWrap.typolink.additionalParams.cObject = COA
             40.stdWrap.typolink.additionalParams.cObject {

                  10 = TEXT
                  10.data = GPvar : no_cache 
                  10.wrap = &no_cache=|
                  10.required = 1

                  20 = TEXT
                  20.data = GPvar : L
                  20.wrap = &L=|
                  20.required = 1

                  30 = TEXT
                  30.data = GPvar : backPID
                  30.wrap = &backPID=|
                  30.required = 1

                  40 = TEXT
                  40.data = GPvar : tt_news
                  40.wrap = &tt_news=|
                  40.required = 1

              }