Search code examples
typo3multilingualtyposcript

Typo3: adds anchor but don't know why


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

Solution

  • 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.