cili
cili

Reputation: 317

TYPO3: Pass current menu page uid as parameter to userFunc

How can I pass menu pages ids to a custom user function? I need it so that I can change some page links which are not valid in TYPO3. They will be parsed in another application.

lib.test = HMENU
lib.test {
  ...
  1 = TMENU
  1 {
    NO = 1
    NO {
        # do not create a link here else there are double <a> tags
        doNotLinkIt = 1
        stdWrap.cObject = CASE
        stdWrap.cObject {
            key.field = doktype
            default = TEXT
            default {
                field = nav_title // title
                typolink.parameter.field = uid
                typolink.wrap = |<span><strong></strong></span>
                typolink.ATagBeforeWrap = 1
                stdWrap.htmlSpecialChars = 1

                postUserFunc = user_productsOnCurrentPage->main
                postUserFunc {
                    // not working
                    pageId.data = {page:uid}
                    pageId.insertData = 1

                    // also not working
                    pageId.field = uid 
                }
            }
    }
  }
  ...
}

Upvotes: 1

Views: 2329

Answers (2)

ammut
ammut

Reputation: 229

This might have a solution to your problem:

In TMENU $cObj->data is set to the page-record for each menu item.

So to pass the page uid of the "current iteration" of hmenu this should do:

postUserFunc.pageId.data = field:uid

credit to this (german) thread.

Upvotes: 3

cili
cili

Reputation: 317

I could access the page ID directly in the user function:

TypoScript:

typolink.userFunc = user_mcfazabosOnCurrentPage->main

PHP:

$pageId = $this->cObj->getFieldVal( 'uid' );

Upvotes: 0

Related Questions