Project

General

Profile

Actions

Bug #99887

open

TypoLink UserFunc in TypoScript seems not to work in 12

Added by Alex Kellner over 1 year ago. Updated 6 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2023-02-08
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I just tried to use a UserFunc for typolink as part of a linkhandler configuration (like Torben shows it in his blog post https://www.derhansen.de/2022/01/typo3-multiple-dynamic-typolink-parameters.html).
The UserFunc is called correctly. But returning a string with a beginning A-tag does not render the link:

class TypoLink
{
    public function createEventLink(array $content, array $config): string
    {
        return '<a href="/">';
    }
}


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #99886: Linkhandler with UserFunc - no ContentObjectRenderer availableClosed2023-02-08

Actions
Actions #1

Updated by Benni Mack about 1 year ago

  • Status changed from New to Needs Feedback

Hi Alex,

can you attach the TypoScript you're using?

Actions #2

Updated by Alex Kellner about 1 year ago

Sorry Benni,

meanwhile I switched to a TypoScript-Only solution in LUX to get linkhandler to work. Also "Local History" in PhpStorm is empty for the file.
With this issue I opened a second one with #99886 - maybe that helps you (even if the issue is a bit different).

Alex

Update I think it was exactly like Torben shows it in his blogpost like:

config {
    recordLinks {
        registration {
            typolink {
                parameter = 1
                userFunc = DERHANSEN\SfEventMgt\UserFunc\TypoLink->createEventLink
                userFunc {
                    eventUid = TEXT
                    eventUid.data = field:event
                    registrationUid = TEXT
                    registrationUid.data = field:uid
                }
            }
        }
    }
}
Actions #3

Updated by Benni Mack about 1 year ago

  • Related to Bug #99886: Linkhandler with UserFunc - no ContentObjectRenderer available added
Actions #4

Updated by cosmoblonde GmbH 29 days ago

Hi,
we are experiencing the same issue for a project we are upgrading from a working LTS 11 version to 12.

It seems that the userfunc return value is not used in any way for the typolink generation.
We did double check and can confirm that our userfunc is returning a full (and valid) a-tag.
(We even tried with only returning an opening a-tag as suggested by some source)
If we comment out our userFunc line in our TS, a link is generated to the parameter pid given in our typoscript.

Therefore we assume userFunc is not working with typolink in v12.

Are there any news on this issue? Or can you at least confirm, it is an open issue?

Thank you!
Ulrike

Actions #5

Updated by Benni Mack 29 days ago

Hey Ulrike,

does your userFunc return a string or a LinkResult object?

Actions #6

Updated by cosmoblonde GmbH 24 days ago

Hey Benni,

currently we are returning a string but if it is required we can switch to a LinkResult object.

Actions #7

Updated by cosmoblonde GmbH 11 days ago

Hi,

any news or hints regarding this userFunc issue?

Thank you!
Ulrike

Actions #8

Updated by Benni Mack 8 days ago

cosmoblonde GmbH wrote in #note-7:

Hi,

any news or hints regarding this userFunc issue?

Thank you!
Ulrike

Hey Ulrike,

yes. feel free to ping me (e.g. on slack https://typo3.org/community/meet/chat-slack) so we can exchange the code, if that's ok.

Actions #9

Updated by cosmoblonde GmbH 6 days ago

Hey Benni,

thanks for your offer to directly communicate - I appreciate it!

In the meantime I have already found a solution for my specific problem by using the following typoscript structure:

Working TypoScript structure:

     customLinkType {
           typolink {

                # Detail page
                parameter.cObject = USER
                parameter.cObject {
                    userFunc = Myvendor\MyExtension\UserFunc\MyClass->buildLink
                    item.data = field:uid
                    # PID used if no detail page can be found
                    fallback = 13
                }
                additionalParams.data = field:uid
                additionalParams.wrap = &tx_myextension_dummy[controller]=MyController&tx_myextension_dummy[action]=show&tx_myextension_dummy[item]=|

            }
            forceLink = 1
        }

In that working example the userFunc is "only" returning the required PID of the target page, which - for my use case - is a good and clean solution.

Nevertheless, in the non-working version we tried to generate the complete link via a userFunc, which worked until TYPO3 v11 but with version 12 the returned link is never passed on and no links appear in the frontend.

Failing TypoScript structure:

     customLinkType {
           typolink {
                # parameter only set as dummy
                parameter = 1

                # additionalParams are available to the userFunc, so are used to pass the current field:uid to that function
                additionalParams.data = field:uid
                additionalParams.wrap = &UID=|&

                userFunc = Myvendor\MyExtension\UserFunc\MyClass->buildLink
            }
            forceLink = 1
        }

So for my example the new solution is preferable but it would be good for other use cases to be able to generate complete anchor links via a userFunc.

Thank you!

Actions

Also available in: Atom PDF