是否可以在我自己的扩展名中扩展realurl配置?我尝试了以下操作,但不起作用:
//ext_localconf.php of my extension
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['postVarSets']['_DEFAULT'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['postVarSets']['_DEFAULT'],
[
'gallery' => [
[
'GETvar' => 'tx_myext_p1gallery[gallery]',
'lookUpTable' => [
'table' => 'tx_myext_domain_model_gallery',
'id_field' => 'uid',
'alias_field' => 'title',
'maxLength' => 120,
'useUniqueCache' => 1,
'addWhereClause' => ' AND NOT deleted',
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 5,
'useUniqueCache_conf' => [
'spaceCharacter' => '_'
]
]
],
],
'controller' => [
[
'GETvar' => 'tx_myext_p1gallery[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[controller]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[backId]',
'noMatch' => 'bypass',
],
],
]
);
如果我在realurl_conf.php中使用相同的代码,则它可以正常工作。
答案 0 :(得分:0)
您的修改可能要到很晚才被realurl考虑。
Realurl在响应过程的早期执行。直到那时您的扩展程序才可能执行。
由于realurl_config文件在您的控制之下(通常是网站扩展名),并且它只是PHP,因此您还可以在“原始” realurl_conf.php
中添加扩展名修改。
if (file_exists('typo3conf/ext/my_extension/Configuration/realurl_additional_conf.php')) {
include_once('typo3conf/ext/my_extension/Configuration/realurl_additional_conf.php');
}
答案 1 :(得分:0)
RealURL为此具有一个“ autoconf”钩子。
您必须在ext_localconf.php
中输入:
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['my_extkey'] = \Vendor\Ext\Hooks\RealUrlAutoConfiguration::class . '->addConfig';
}
您的班级可能看起来像这样:
<?php
namespace Vendor\Ext\Hooks;
class RealUrlAutoConfiguration
{
/**
* Generates additional RealURL configuration and merges it with provided configuration
*
* @param array $params Default configuration
*
* @return array Updated configuration
*/
public function addConfig($params)
{
return array_merge_recursive($params['config'], [
'postVarSets' => [
'_DEFAULT' => [
'gallery' => [
[
'GETvar' => 'tx_myext_p1gallery[gallery]',
'lookUpTable' => [
'table' => 'tx_myext_domain_model_gallery',
'id_field' => 'uid',
'alias_field' => 'title',
'maxLength' => 120,
'useUniqueCache' => 1,
'addWhereClause' => ' AND NOT deleted',
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 5,
'useUniqueCache_conf' => [
'spaceCharacter' => '_'
]
]
],
],
'controller' => [
[
'GETvar' => 'tx_myext_p1gallery[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[controller]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[backId]',
'noMatch' => 'bypass',
],
],
]
]
]);
}
}
仅当您在RealURL扩展配置(在扩展管理器中)激活了自动配置功能时,此功能才起作用