Alte TYPO3 Link-Tags in A-Tags umwandeln

Bis TYPO3 v8 wurden noch Link-Tags im RTE bei Verwendung von rtehtmlarea als Editor erzeugt. Um diese in A-Tags umzuwandeln, dient folgende Vorgehensweise. Hinweis: Dieses Vorgehen ist aber nur ratsam, wenn es sich bei den eingestellten Links, ausschließlich um externe Links handelt. Interne Links werden nicht korrekt aufgelöst.
DROP FUNCTION IF EXISTS ReplaceFirstGreaterThanAfterLink;
DELIMITER //
CREATE FUNCTION ReplaceFirstGreaterThanAfterLink(input_text TEXT)
RETURNS TEXT
BEGIN
    DECLARE link_position INT;
    DECLARE greater_than_position INT;
    -- Find the position of the first '<link '
    SET link_position = LOCATE('<link ', input_text);
    -- Check if '<link is found while link_position> 0 DO
        -- Find the position of the first '>' after '<link set greater_than_position="LOCATE('">', input_text, link_position);
        -- Check if '>' is found after '<link if greater_than_position> 0 THEN
            -- Replace the first '>' after '<link set input_text="CONCAT(" greater_than_position>',
                SUBSTRING(input_text FROM greater_than_position + 1)
            );
        END IF;
        -- Replace the first '<link ' with '<a href="'
        SET input_text = CONCAT(
            SUBSTRING(input_text, 1, link_position - 1),
            '<a href="',
            SUBSTRING(input_text FROM link_position + LENGTH('<link '))
        );
        -- Find the next position of '<link '
        SET link_position = LOCATE('<link ', input_text);
    END WHILE;
    -- Replace '' with ''
    SET input_text = REPLACE(input_text, '', '');
    RETURN input_text;
END //
DELIMITER ;

Die SQL-Prozedur kann dann wie folgt für jedes beliebige Tabellenfeld aufgerufen werden.

Für das bodytext Feld der news-Extension, kann folgende Anweisung verwendet werden:

UPDATE tx_news_domain_model_news
SET bodytext = ReplaceFirstGreaterThanAfterLink(bodytext);

Und für das bodytext Feld normaler Content-Elemente, kann folgende Anweisung verwendet werden:

UPDATE tt_content
SET bodytext = ReplaceFirstGreaterThanAfterLink(bodytext);

Hier finden sich Informationen zu dem veralteten TYPO3 Link-Tag:
https://www.jochenfroehlich.com/tutorial/typo3-link.html


Erstellt am: