Paul
Paul

Reputation: 289

Extend TypoLink Function to append GET parameters depending on pId

Hoe can I extend the TypoLink generation Function that every time a TypoLink is being generated it checks for a certain targetpId and then append the id of the current page as a GEt argument. For example:

When a Link on the page with ID 5 targets the page with the ID 19 then add ?ref=5 to the link

I currently don't know where to start, which Class/Method can I try to Override to include this kind of behaviour.

Upvotes: 0

Views: 836

Answers (1)

owned139
owned139

Reputation: 101

Extending Classes (XCLASSes)

I dont know about TYPO3 9.5 but we did it in 8.7. Here is a snippet about the extended classes we used:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Frontend\Page\PageRepository::class] = array(
    'className' => Vendor\Extension\Page\PageRepository::class
);

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class] = array(
    'className' => Vendor\Extension\ContentObject\ContentObjectRenderer::class
);

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Core\DataHandling\DataHandler::class] = array(
    'className' => Vendor\Extension\DataHandling\DataHandler::class
);

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::class] = array(
    'className' => Vendor\Extension\Typolink\PageLinkBuilder::class
);

Its not exactly what you are searching for but a good way to start.

Upvotes: 1

Related Questions