Bug #81620

Linkhandler remove all attributes set in the link wizard and the template

Added by Kevin Appelt about 2 years ago. Updated 15 days ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Start date:
2017-06-19
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
linkhandler, typolink
Complexity:
medium
Is Regression:
Sprint Focus:

Description

My configuration

I am using version TYPO3 CMS 8.7.1 and the linkhandler from core.

I have a template like this:

<f:link.typolink parameter="{link}" class="btn more">Mehr erfahren</f:link.typolink>

I have the following pageTsConfig:

TCEMAIN {
    linkHandler {
        tx_news {
            handler = TYPO3\CMS\Recordlist\LinkHandler\RecordLinkHandler
            label = News
            configuration {
                table = tx_news_domain_model_news
                hidePageTree = 0
            }
            scanAfter = page
        }
    }
}

And this typoscript:

config {
    recordLinks {
        tx_news {
            typolink {
                parameter = {$id.newsDetailPid}
                additionalParams.data = field:uid
                additionalParams.wrap = &tx_news_pi1[news]=|&tx_news_pi1[action]=detail&tx_news_pi1[controller]=news
                useCacheHash = 1
            }
        }
    }
}

{$id.newsDetailPid} is set as 22.

The scenario

Now i create a link with the link wizard to a page (uid: 30) with some extra attributes set

t3://page?uid=30 _blank "btn special" Testtitle google=bad

and get this:
<a href="/index.php?id=1&google=bad" title="Testtitle" target="_blank" class="btn special more">Mehr erfahren</a>

Now i create a link with the link wizard to a news record (uid:1) with the same extra attributes set
t3://record?identifier=tx_news&uid=1 _blank "btn special" Testtitle google=bad

and get this:
<a href="/index.php?id=22&tx_news_pi1%5Bnews%5D=1&amp;tx_news_pi1%5Baction%5D=detail&amp;tx_news_pi1%5Bcontroller%5D=news&amp;cHash=e68aca14db3f2e4bc194845e951acc11">Mehr erfahren</a>

The problem

If i use a link created with linkhandler all attributes get completly removed.
I think the problem is somewhere in the method typoLink in /typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php but i am not sure.

One way it works to add the classes - but it is not useful

To add the classes i have to set them in the `parameter` in the typoscript of the linkhandler.
But this is not what is needed, because there is no class for “link to news” but the tags may have classes like in the example.


Related issues

Related to TYPO3 Core - Bug #81903: DatabaseRecordLinkBuilder is ignoring other settings Closed 2017-07-18
Related to TYPO3 Core - Bug #80896: TypolinkViewhelper with linkhandler ignores class attribute New 2017-04-19
Related to TYPO3 Core - Bug #84942: target _blank is beeing ignored on CType "images" with recordLinks Closed 2018-05-07
Related to TYPO3 Core - Bug #85868: Tests are not executed Closed 2018-08-15
Related to TYPO3 Core - Bug #81316: linkhandler does not respect custom typolink configuration Closed 2017-05-23

Associated revisions

Revision f52e3a36 (diff)
Added by Susanne Moog 11 months ago

[BUGFIX] Use params set in db in recordLinkHandler

Resolving of links with a custom record link handler is now done
in the following order:

- TypoScriptConfiguration Parameters
- Parameters set in link field in content element
- If param is empty in link field but set in config that is taken into
account as a fallback
- It is not possible to unset a value (class, title, target, link) in
the link field if it is set to a default value in TypoScript

Caveat: Overwriting attributes only works if they are set via parameter
in configuration not if they are set via ATagParams.

Resolves: #81620
Releases: master, 8.7
Change-Id: Ie723e7d7d36a03bac4ec97211749317d7311dd3e
Reviewed-on: https://review.typo3.org/57370
Tested-by: TYPO3com <>
Reviewed-by: Markus Klein <>
Reviewed-by: Ralf Merz <>
Reviewed-by: Jörg Bösche <>
Reviewed-by: Marc Hirdes <>
Reviewed-by: Maik Peuser <>
Reviewed-by: Tim Schreiner <>
Tested-by: Tim Schreiner <>
Reviewed-by: Andreas Fernandez <>
Tested-by: Andreas Fernandez <>

Revision 09a0be52 (diff)
Added by Susanne Moog 11 months ago

[BUGFIX] Use params set in db in recordLinkHandler

Resolving of links with a custom record link handler is now done
in the following order:

- TypoScriptConfiguration Parameters
- Parameters set in link field in content element
- If param is empty in link field but set in config that is taken into
account as a fallback
- It is not possible to unset a value (class, title, target, link) in
the link field if it is set to a default value in TypoScript

Caveat: Overwriting attributes only works if they are set via parameter
in configuration not if they are set via ATagParams.

Resolves: #81620
Releases: master, 8.7
Change-Id: Ie723e7d7d36a03bac4ec97211749317d7311dd3e
Reviewed-on: https://review.typo3.org/57883
Tested-by: TYPO3com <>
Reviewed-by: Andreas Fernandez <>
Tested-by: Andreas Fernandez <>

Revision d525bcb0 (diff)
Added by Benni Mack 10 months ago

[BUGFIX] Move test file to right location

The tests in change https://review.typo3.org/57370/
have been put in the wrong folder and are never
executed by the TYPO3 Core Unit Test suite.

This patch moves the file into the right location.

Resolves: #85868
Related: #81620
Releases: master, 8.7
Change-Id: I8cb95031c3198d1955ee800b2137b770400acde8
Reviewed-on: https://review.typo3.org/57922
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>
Tested-by: TYPO3com <>
Reviewed-by: Jörg Bösche <>
Tested-by: Jörg Bösche <>
Reviewed-by: Tymoteusz Motylewski <>
Tested-by: Tymoteusz Motylewski <>

Revision ccb2361e (diff)
Added by Benni Mack 10 months ago

[BUGFIX] Move test file to right location

The tests in change https://review.typo3.org/57370/
have been put in the wrong folder and are never
executed by the TYPO3 Core Unit Test suite.

This patch moves the file into the right location.

Resolves: #85868
Related: #81620
Releases: master, 8.7
Change-Id: I8cb95031c3198d1955ee800b2137b770400acde8
Reviewed-on: https://review.typo3.org/57924
Tested-by: TYPO3com <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Gerrit Code Review about 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53275

#2 Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53275

#3 Updated by Gerrit Code Review almost 2 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53275

#4 Updated by Gerrit Code Review almost 2 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53275

#5 Updated by Markus Klein almost 2 years ago

  • Complexity set to medium
  • Sprint Focus set to On Location Sprint

#6 Updated by Mathias Brodala almost 2 years ago

  • Duplicated by Bug #81903: DatabaseRecordLinkBuilder is ignoring other settings added

#7 Updated by Mathias Brodala almost 2 years ago

  • Duplicated by deleted (Bug #81903: DatabaseRecordLinkBuilder is ignoring other settings)

#8 Updated by Dennis Römmich almost 2 years ago

What should be the expected behavior if i have the following link within the RTE:

<a class="btn special" title="Testtitle" href="t3://record?identifier=tx_news&uid=1">convallis</a>

I think this behavior is not covered by the given patch in gerrit, isn't it?

#9 Updated by Anja Leichsenring almost 2 years ago

  • Sprint Focus deleted (On Location Sprint)

#10 Updated by Stefan Galinski over 1 year ago

This is not a bug. Just a configuration issue.

Working example configuration:

config.recordLinks {
    pressRelease {
        forceLink = 0
        typolink {
            parameter = {$themes.pages.news.pressReleaseSingle}
            additionalParams = &tx_news_pi1[news]={field:uid}
            additionalParams.insertData = 1
            useCacheHash = 1

            ATagParams.data = parameters:allParams
            target.data = parameters:target
            title.data = parameters:title

            extTarget = _blank
            extTarget.override.data = parameters:target
        }
    }
}

#11 Updated by Francois Suter over 1 year ago

The above is true for a link inside the RTE, but when coming from a TS configuration or a Fluid view helper, the ContentObjectRenderer class does not load the link parameters into the parameters member variable.

This is actually quite a touchy issue as several sources of information must be combined:
  1. the additional parameters of the link itself
  2. the ViewHelper or the TS configuration driving the rendering with its own parameters
  3. the "base" linkhandler TS configuration

The difficulty lies in defining how each "level" overrides the other. The "parameter" and "additionalParams" properties should be carefully preserved because they are calculated in \TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder::build().

I do not have a good answer for now...

#12 Updated by Christian Kuhn over 1 year ago

  • Related to Bug #81903: DatabaseRecordLinkBuilder is ignoring other settings added

#13 Updated by Marc Hirdes over 1 year ago

The Fluid Typolinkviewhelper adds a parameter string like

parameter = t3://record?identifier=tx_news&uid=1 _blank "btn special" Testtitle google=bad

The sysext/frontend/Classes/Typolink/DatabaseRecordLinkBuilder.php creates a parameter string like the following, if 15 is the page uid of the detail page

parameter = 15

So all other settings will be ignored. Usefull would be a merge of the settings in the DatabaseRecordLinkBuilder

$typoScriptConfiguration = $configuration[$configurationKey]['typolink.'];

        /** @var TypoLinkCodecService $typoLinkCodecService */
        $typoLinkCodecService = GeneralUtility::makeInstance(TypoLinkCodecService::class);
        $typoScriptConfiguration['parameter'] = $typoLinkCodecService->encode(
            array_merge(
                array_filter($typoLinkCodecService->decode($conf['parameter']), 'strlen'),
                array_filter($typoLinkCodecService->decode($typoScriptConfiguration['parameter']), 'strlen')
            )
        );

A fix in the core would be great.

#14 Updated by DANIEL Rémy over 1 year ago

  • Related to Bug #80896: TypolinkViewhelper with linkhandler ignores class attribute added

#15 Updated by Elena Bartolotti about 1 year ago

  • Related to Bug #84942: target _blank is beeing ignored on CType "images" with recordLinks added

#16 Updated by Gerrit Code Review 11 months ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57370

#17 Updated by Gerrit Code Review 11 months ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57883

#18 Updated by Susanne Moog 11 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#19 Updated by Benni Mack 10 months ago

  • Related to Bug #85868: Tests are not executed added

#20 Updated by Benni Mack 9 months ago

  • Status changed from Resolved to Closed

#21 Updated by Markus Klein 8 months ago

  • Related to Bug #81316: linkhandler does not respect custom typolink configuration added

#22 Updated by Sergio Catalá 15 days ago

Is this fixed for TYPO3 9.5?
I can find the same wrong behaviour described.

Also available in: Atom PDF