-->

Typo3: adds anchor but don't know why

2020-03-06 03:23发布

问题:

I have a page content element on a page. This has the ID 3 and it has a translation. This element is read out with the following Typoscript

lib.marker = RECORDS
lib.marker {
  tables=tt_content
    source= 3
    dontCheckPid = 1
  languageField = sys_language_uid
    select.languageField = sys_language_uid
}

For the default language everything is OK. But for my additional language I get

<a id="c605"></a>

before the div I originally wanted is displayed. I looked in the HTML of the page content and there is everything like it should be. Any ideas?

Edit:

Here the content gathered through the TS Object Browser:

[tt_content] = CASE
    [key]
    [stdWrap]
        [innerWrap]
        [innerWrap2] = | <p class="csc-linkToTop"><a href="#">{LLL...
        [prepend] = TEXT
            [dataWrap] = <a id="c{field:_LOCALIZED_UID}"></a>
            [if]
                [isTrue]
                    [field] = _LOCALIZED_UID

回答1:

The default behaviour should be that the anchor is added even in the default language. However, I've just checked and realized that there might be a bug in TYPO3 for which reason I'm actually using different setup.

I think you have 2 options.

a) Unset the anchor completely:

tt_content.stdWrap.prepend >

b) Modify the anchor this way:

tt_content.stdWrap.prepend {
  if >
  dataWrap = <a id="c{field:_LOCALIZED_UID//field:uid}" class="anchor"></a>
}

This should give you an anchor consistently in both default and localized version. Then you should set CSS for a.anchor so that it doesn't screw your layout. I don't know what kind of layout problems it gives so I currently cannot give you more advice on that.

NOTE: The solution works in TYPO3 4.5, might work in later versions but is reported not to work in version 9.x.x and later.



回答2:

I use following to get rid of unwanted anchor tag

tt_content.stdWrap.prepend >
tt_content.stdWrap.innerWrap.cObject.66.10 >


回答3:

I used tt_content.stdWrap.prepend > to remove the anchors, but was still getting them.

Looking a tt_content, anchors are also prepended in to content elements with "no frame" (section_frame = 66).

This should get rid of them:

tt_content.stdWrap.innerWrap.cObject.66.10 >

(Typo3 v4.6)