1
votes

I want to display my own extension in TYPO3's CE Shortcut.

The button for my extension is displayed under the listview as button. And I can select an entry and it's saved. But I can't access the selected id in the frontend.

What I tried so far:

I added in /Configuration/TCA/Overrides/tt_content.php the Method addToInsertRecords. So the button to select an entry is shown up in the backend.

defined('TYPO3_MODE') or die();
call_user_func(function () {
  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToInsertRecords('tx_eislist_domain_model_eis');
});

To show in Frontend the Typoscript is:

tt_content.shortcut.20.tables := addToList(tx_eislist_domain_model_eis)
tt_content.shortcut.20.conf.tx_eislist_domain_model_eis = USER
tt_content.shortcut.20.conf.tx_eislist_domain_model_eis {
  userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
  extensionName = EisList
  pluginName = Eis
  vendorName = Emma
  controller = Eisbar
  action = show
  switchableControllerActions {
    Eisbar {
      1 = show
    }
  }

  settings =< plugin.tx_eislist_eis.settings
  settings {
    insertRecord = 1
    useStdWrap = singleRecords
    displayMode = single
    singleRecords.field = uid
  }
}
tt_content.shortcut.variables.shortcuts.tables := addToList(tx_eislist_domain_model_eis)
tt_content.shortcut.variables.shortcuts.conf.tx_eislist_domain_model_eis < tt_content.shortcut.20.conf.tx_eislist_domain_model_eis

In PHP with

$this->settings['singleRecords']

I can access the variable from TypoScript. But I get the string "field" => "uid". Instead of the selected value ID.

1

1 Answers

0
votes

I think you need to inject configurationManager to get stdWrap functionality from / in setup typoscript file. Just use a configurationManager variable and an injectFunction in your controller which contains the show action:

 /**
 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
 */
protected $configurationManager;

/**
 * Injects the Configuration Manager and is initializing the framework settings
 *
 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager Instance of the
 *     Configuration Manager
 */
public function injectConfigurationManager(
    \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
) {
    $this->configurationManager = $configurationManager;
    $originalSettings = $this->configurationManager->getConfiguration(
        \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS
    );

    // Use stdWrap for given defined settings
    if (isset($originalSettings['useStdWrap']) && !empty($originalSettings['useStdWrap'])) {
        $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
        $typoScriptArray = $typoScriptService->convertPlainArrayToTypoScriptArray($originalSettings);
        $stdWrapProperties = GeneralUtility::trimExplode(',', $originalSettings['useStdWrap'], true);
        foreach ($stdWrapProperties as $key) {
            if (is_array($typoScriptArray[$key . '.'])) {
                $originalSettings[$key] = $this->configurationManager->getContentObject()->stdWrap(
                    $typoScriptArray[$key],
                    $typoScriptArray[$key . '.']
                );
            }
        }
    }
    $this->settings = $originalSettings;
}