Project

General

Profile

Actions

Bug #60635

closed

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

Added by Christian Heindl over 10 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Pagetree
Target version:
Start date:
2014-07-28
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
medium
Is Regression:
Yes
Sprint Focus:

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)

Actions #1

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

Actions #2

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

Actions #3

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']);

Actions #4

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

Actions #5

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?

Actions #6

Updated by Christian Heindl over 10 years ago

Yes, it now it works for me.

Actions #7

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

Actions #8

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

Actions #9

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.

Actions #10

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

Actions #11

Updated by Helmut Hummel over 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #12

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF