Typo3 8.7.x / Extbase / Realurl: 为生成的 html 页面添加前缀
Typo3 8.7.x / Extbase / Realurl: Add prefix for generated html page
是否可以通过 realurl 为我的扩展生成的页面添加前缀?我正在使用以下配置:
...
'postVarSets' => [
'_DEFAULT' => [
'gallery' => [
[
'GETvar' => 'tx_myext_p1gallery[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[controller]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[backId]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[gallery]',
'lookUpTable' => [
'table' => 'tx_myext_domain_model_gallery',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => 'AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => [
'strtolower' => 1,
'spaceCharacter' => '-',
],
],
],
[
'GETvar' => 'tx_myext_p1gallery[page]',
],
],
现在我有一个 url 这样的:
https://www.mydomain/galerie/2016-foobar/1.html
但我想要这个 https://www.mydomain/galerie/2016-foobar/page1.html
据我所知,唯一的解决方案是使用 userFunc 添加此行为。
[
'GETvar' => 'tx_myext_p1gallery[page]',
'userFunc' => SomeClass::class . '->somefunction'
],
然后您的函数应在编码时添加页面前缀或在解码时删除前缀。
public function somefunction($parameters = [])
{
$value = $parameters['value'];
if ($parameters['decodeAlias']) {
return preg_replace('#^page([0-9]*)$#i', '', $value);
} else {
return 'page' . $value;
}
}
是否可以通过 realurl 为我的扩展生成的页面添加前缀?我正在使用以下配置:
...
'postVarSets' => [
'_DEFAULT' => [
'gallery' => [
[
'GETvar' => 'tx_myext_p1gallery[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[controller]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[backId]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[gallery]',
'lookUpTable' => [
'table' => 'tx_myext_domain_model_gallery',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => 'AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => [
'strtolower' => 1,
'spaceCharacter' => '-',
],
],
],
[
'GETvar' => 'tx_myext_p1gallery[page]',
],
],
现在我有一个 url 这样的: https://www.mydomain/galerie/2016-foobar/1.html 但我想要这个 https://www.mydomain/galerie/2016-foobar/page1.html
据我所知,唯一的解决方案是使用 userFunc 添加此行为。
[
'GETvar' => 'tx_myext_p1gallery[page]',
'userFunc' => SomeClass::class . '->somefunction'
],
然后您的函数应在编码时添加页面前缀或在解码时删除前缀。
public function somefunction($parameters = [])
{
$value = $parameters['value'];
if ($parameters['decodeAlias']) {
return preg_replace('#^page([0-9]*)$#i', '', $value);
} else {
return 'page' . $value;
}
}