Add parameter to link in typoscript

夙愿已清 提交于 2019-12-10 11:28:45

问题


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.


回答1:


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

              }



回答2:


According to typolink reference you need to use additionalParams

lib.myLink = TEXT
lib.mylink.value = Click me!
lib.mylink.typolink.parameter.data = page:uid
lib.mylink.typolink.additionalParams = &mainsite=1
lib.mylink.typolink.useCacheHash = 1

Keep in mind that each (even first) parameter in additionalParams begins with &. Most probably you'll need also make sure that it will generate cHash for proper caching.



来源:https://stackoverflow.com/questions/11919556/add-parameter-to-link-in-typoscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!