繁体   English   中英

使用typo3和realurl从网址中删除控制器

[英]Remove controller from url with typo3 and realurl

我正在构建更复杂的url,我希望它们很好并且没有不必要的信息。

因此,我不想在我的URL中使用typo3控制器。 我通过使用<f:link.page>而不是<f:link.action>链接<f:link.action>链接。

现在,我想对表单的唯一流体执行相同操作,从而自动将控制器广告添加到链接。 我尝试了以下表单代码,但它也添加了当前控制器:

<f:form class="limitform" method="post" enctype="multipart/form-data" pageUid="1" additionalParams="{extension: {page: '1'}}">

有没有办法不添加控制器?

您可以在RealURL配置中删除控制器和/或操作。 下面是一个示例,该示例从详细信息链接中删除了动作和控制器。

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array (
    '_DEFAULT' => array (
        'init' => array (
            'enableCHashCache' => '1',
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => '1',
            'enableUrlEncodeCache' => '1',
        ),
        'fixedPostVars' => array (
                'yourDetailConfiguration' => array(
                        array(
                                'GETvar' => 'tx_yourext_pi[action]',
                                'valueMap' => array(
                                        'detail' => '',
                                ),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_yourext_pi[controller]',
                                'valueMap' => array(
                                        'Event' => '',
                                ),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_yourext_pi[event]',
                                'lookUpTable' => array(
                                        'table' => 'tx_yourext_domain_model_yourtable',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'addWhereClause' => ' AND NOT deleted',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' => array(
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-'
                                        ),
                                        'languageGetVar' => 'L',
                                        'languageExceptionUids' => '',
                                        'languageField' => 'sys_language_uid',
                                        'transOrigPointerField' => 'l10n_parent',
                                        'autoUpdate' => 1,
                                        'expireDays' => 180,
                                )
                        )
                ),
                '123' => 'yourDetailConfiguration',
        ),
);

请注意,您必须将带有插件的每个页面UID (在本例中为页面123,其中包含详细信息页面)分配给所需的配置。

有关更多信息,请参见新闻扩展的扩展手册 在那里,您还将找到上述解决方案的替代方案,以删除控制器/动作。

最好的方法是使用“ fixedPostVars”(参见其他答案)构建口语网址,然后使用来自realurl的编码钩子清理长网址:

// Replace
$TYPO3_CONF_VARS['EXTCONF']['realurl']['encodeSpURL_postProc'] = array('user_encodeSpURL_postProc');
$TYPO3_CONF_VARS['EXTCONF']['realurl']['decodeSpURL_preProc'] = array('user_decodeSpURL_preProc'); //

function user_encodeSpURL_postProc(&$params, &$ref) {
    $params['URL'] = str_replace('auto/contoller/Ads/', 'auto/Ads', $params['URL']);
}

function user_decodeSpURL_preProc(&$params, &$ref) {
    $params['URL'] = str_replace('auto/Ads', 'auto/contoller/Ads/', $params['URL']);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM