【问题标题】:typolink userFunc in TYPO3 V8TYPO3 V8 中的错字链接 userFunc
【发布时间】:2017-10-19 18:34:05
【问题描述】:

我想使用核心链接处理程序并在 userFunc 中更改我的链接。

我使用此处描述的链接处理程序,它适用于单个详细信息页面: https://usetypo3.com/linkhandler.html

问题是: 如果我将打字稿更改为:

config.recordLinks {
    tx_news {
        typolink {
            userFunc = Vendor\Name\UserFunc\TypolinkUserFunc->parseLinkHandlerTypolink
            userFunc {
                newsUid = TEXT
                newsUid.data = field:uid

                newsClass = TEXT
                newsClass.data = parameters:class

                defaultDetailPid = 53
            }
        }
    }
}

它不起作用。

我无法处理 userFunc。我在扩展程序中。我用

'autoload' =>
        array(
            'psr-4' => array('Vendor\\Name\\' => 'Classes')
        ),
);

为了加载我的 userFunc 类。 我没有收到任何错误消息。

【问题讨论】:

  • 类文件是my_ext/Classes/UserFunc/TypolinkUserFunc.php?该课程的外观如何(完整源代码)?它是否在没有 config.recordLinks 上下文的情况下工作,例如page.10 = USER_INT, page.10.userFunc = Vendor\Name\UserFunc\TypolinkUserFunc->parseLinkHandlerTypolink ?否则,使用调试器并在 sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php 行 5712 中设置断点。
  • 您是否阅读了typlink 中的userFunc 文档? docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/…。您也可以发布您的 userFunc 代码吗?

标签: typo3 tx-news typo3-8.x typo3-8.7.x


【解决方案1】:

您现在一定已经想通了,但您必须以USER 的身份运行 userFunc。

10 = USER
10 {
    userFunc = TYPO3\Extension\Sample->user_exampleUserFunc
}

因此,作为示例,您的代码应如下所示:

config.recordLinks {
    tx_news {
        typolink {
            10 = USER
            10 {
                userFunc = Vendor\Name\UserFunc\TypolinkUserFunc->parseLinkHandlerTypolink
                userFunc {
                    newsUid = TEXT
                    newsUid.data = field:uid

                    newsClass = TEXT
                    newsClass.data = parameters:class

                    defaultDetailPid = 53
                }
            }
        }
    }
}

以上只是一个示例,它应该可以帮助您入门。

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-14
    • 2013-11-19
    • 1970-01-01
    • 2014-10-28
    相关资源
    最近更新 更多