webman
webman

Reputation: 1203

How to add a parameter to the url with typoscript in TMENU

with the following snippet I get an ID counting up for every following menu item, this is the html output:

 <a href="http://example.com/index.php?id=17" id="item-1"> <!-- item-2 etc -->

but I'd need this counting up with the following output:

<a href="http://example.com/index.php?id=17&item=1"> <!-- item=2 etc -->

the snippet:

1 = TMENU
1 {
    expAll = 1

    NO = 1
    NO {
        before.cObject = LOAD_REGISTER
        before.cObject{
            fontawesome.cObject=TEXT
            fontawesome.cObject.required = 1
            fontawesome.cObject.data.dataWrap = DB:pages:{field:uid}:tt_content_fontawesome_icon
            fontawesome.cObject.noTrimWrap = | <i class="fa |"></i> |
        }
        ATagBeforeWrap = 1
        linkWrap = {register:fontawesome}|
        ATagParams = id="item-{register:count_MENUOBJ}"
        allStdWrap.insertData = 1
        wrapItemAndSub = <li>|</li>
        stdWrap.htmlSpecialChars = 1
    }
}

I tried with typolink {} and additionalParams but that makes {register:count_MENUOBJ} unavailable for a reason I cannot grasp, probabely some conflict within data types ...

also the linkwrap with {register:fontawesome} is delicate ...

Upvotes: 0

Views: 1155

Answers (1)

user7086933
user7086933

Reputation: 36

Inside of NO {} try these two lines without allStdWrap.insertData:

additionalParams.data = register:count_MENUOBJ
additionalParams.wrap = &item=|

If it would not work, try another value to check if it basically would work:

additionalParams.data = field:uid
additionalParams.wrap = &item=|

Have a look at the documentation: https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html

Upvotes: 2

Related Questions