我的网址是
backPid = 5&tx_viextendednews_newsblog%5Baction%5D =显示&tx_viextendednews_newsblog%5Bcontroller%5D = Extendednews&tx_viextendednews_newsblog%5Bextendednews%5D = 1
而且我想成功
/新闻细节/ newstitle /?backpid = 5
我在我的ext_local.conf文件中写了$ GLOBALS ['TYPO3_CONF_VARS'] ['SYS'] ['routing'] ['CustomPlugin'] = \ VrisiniInfotechLLP \ ViExtendednews \ Routing \ CustomEnhancer :: class;
我的替代者是
class CustomEnhancer extends AbstractEnhancer implements RoutingEnhancerInterface, ResultingInterface
{
/**
* @var array
*/
protected $configuration;
/**
* @var string
*/
protected $namespace;
public function __construct(array $configuration)
{
$this->configuration = $configuration;
$this->namespace = $this->configuration['namespace'] ?? '';
}
}
我的config.yaml路径是/siteroot/typo3conf/sites/foldername/config.yaml
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [13]
extension: Extendednews
plugin: newsblog
routes:
- { routePath: '/detail/{news_title}', _controller: 'Extendednews::show', _arguments: {'news_title': 'news'} }
defaultController: 'Extendednews::show'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
routeValuePrefix: '/'
我怎么能理解这个文件在内部工作?现在Mys问题是我应该写在这个文件中,以便我可以得到所需的网址?
我将以下代码用于自己的路由方面。使用DebuggerUtility :: var_dump($ value)查看此Aspect类中发生的情况:
<?php
namespace VENDOR\MyExtension\Routing\Aspect;
use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;
use TYPO3\CMS\Core\Site\SiteLanguageAwareTrait;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
class IdentifierValueMapper implements StaticMappableAspectInterface
{
use SiteLanguageAwareTrait;
/**
* {@inheritdoc}
*/
public function generate(string $value): ?string
{
return $value !== false ? (string)$value : null;
}
/**
* {@inheritdoc}
*/
public function resolve(string $value): ?string
{
return isset($value) ? (string)$value : null;
}
}
config.yaml
defaults:
identifierPlaceholder: ''
requirements:
identifierPlaceholder: '^[a-zA-Z0-9]{32}$'
aspects:
identifierPlaceholder:
type: IdentifierValueMapper
localconf.php
// Custom Routing Aspects Mapper
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['IdentifierValueMapper'] = \VENDOR\MyExtension\Routing\Aspect\IdentifierValueMapper::class;