user500665
user500665

Reputation: 1362

typoscript variable in plugin settings?

I am using a custom plugin and I need to add the page title as one of the plugin's settings variables:

plugin.tx_fsearch {
  settings {
    resultsPath = search-results/brand/{field:title}/make/{field:title}
    resultsPath.insertData = 1
  }
}

However this is outputting the word 'Array' instead of the path I need. Does anyone know how I might be able to make this work?

Upvotes: 1

Views: 2206

Answers (2)

Georg Ringer
Georg Ringer

Reputation: 7939

There is no stdWrap available for settings in extbase extensions, no matter if using TEXT cObj or insertData!

As a workaround, you can fix that yourself by doing something like EXT:news does here https://github.com/georgringer/news/blob/master/Classes/Controller/NewsController.php#L495

public function injectConfigurationManager(
    \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
) {
    $this->configurationManager = $configurationManager;
        $typoScriptService = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Service\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(
                    $originalSettings[$key],
                    $typoScriptArray[$key . '.']
                );
            }
        }
    }
    $this->settings = $originalSettings;
}

Or you skip the TS part and call the stdWrap directly in your controller.

Upvotes: 4

jokumer
jokumer

Reputation: 2269

Try TEXT object

plugin.tx_fsearch {
  settings {
    resultsPath = TEXT
    resultsPath.value = search-results/brand/{field.title}/make/{field.title}
  }
}

Upvotes: -2

Related Questions