Bug #60635
closedCannot add calls/links to custom mobule in Page Tree context menu due to FormProtection mechanism
100%
Description
In a project I have added some custom entries within the page tree context menu via typoscript:
// 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)
Updated by Gerrit Code Review over 10 years ago
- Status changed from New to Under Review
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31987
Updated by Helmut Hummel over 10 years ago
Christian Heindl wrote:
Before 6.2 it was no problem to add page tree context menu entries with typoscript (or like above from PHP)
Can you try the WIP patch I pushed? https://review.typo3.org/31987
Updated by Christian Heindl over 10 years ago
Works almost: there is a little typo: it should be
$actionConfiguration['customAttributes.']['contentUrl'] = $this->replaceModuleTokenInContentUrl($actionConfiguration['customAttributes.']['contentUrl']);
instead of
$actionConfiguration['customAttributes.']['contenturl'] = $this->replaceModuleTokenInContentUrl($actionConfiguration['customAttributes.']['contentUrl']);
Updated by Gerrit Code Review over 10 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31987
Updated by Helmut Hummel over 10 years ago
Christian Heindl wrote:
Works almost: there is a little typo: it should be
Ah, sure. Fixed it. Other than that, it does work for you?
Updated by Gerrit Code Review over 10 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31987
Updated by Gerrit Code Review over 10 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31987
Updated by Tymoteusz Motylewski over 10 years ago
The code above didn't work for me at all (no menu entry was added at all).
But the following worked (using news module as example).
Seems that in the above code the TS path was not correct ("options.contextMenu" vs "options.contextMenu.table.pages.items")
$baseUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl( 'web_NewsTxNewsM2', array( 'tx_news_web_newstxnewsm2[action]' => 'newTag', 'tx_news_web_newstxnewsm2[controller]' => 'Administration', ) ); $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] .= ' options.contextMenu.table.pages.items { 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.' } ';
so I validated that the patch works with this code.
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/32338
Updated by Helmut Hummel over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 26abadf5f32e4c10f488c763275a58eca1d23a78.