Issue Bug Closed

#60635Cannot add calls/links to custom mobule in Page Tree context menu due to FormProtection mechanism

Christian Heindl 07/28/14, 10:41 updated 10/02/18, 11:52

Description

In a project I have added some custom entries within the page tree context menu via typoscript:

<?php
// ext_tables.php

$baseUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(
‘web_MyModule’,
array(
‘tx_myextension_web_mymodule[action]’ => ‘myAction’,
‘tx_myextension_web_mymodule[controller]’ => ‘MyController’,
‘id’ => ‘###ID###’,
)
);
$GLOBALS[‘TYPO3_CONF_VARS’][‘BE’][‘defaultUserTSconfig’] .= ‘
options.contextMenu {
750 = ITEM
750 {
name = clickMenuCustomAction
label = Menu Item
icon = ‘ . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . ‘ext_icon.gif’) . ‘
spriteIcon =
callbackAction = openCustomUrlInContentFrame
customAttributes.contentUrl = ‘.$baseUrl.‘
}
’
?>

Add URL contains a “moduleToken” parameter, but it is “dummyToken”. This seems to be generated by the DisabledFormProtection.php. But when “mod.php” is called, BackendFormProtection is used to validate the parameter.

Problems:
  • Here I’m using PHP to generate the custom entry within the page tree context menu. But there are cases, where i would configure such page tree context menu entry within static Typoscript. We need a portable solution to generate valid links to custom modules.
  • The code above is only executed once, so even calls to BackendUtility::getModuleUrl(..) would not retrieve a valid moduleToken, as it is only executed during the initialization of TYPO3 and will be cached across sessions.

Before 6.2 it was no problem to add page tree context menu entries with typoscript (or like above from PHP)

Reviews 2