简体   繁体   English

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

[英]Remove controller from url with typo3 and realurl

I'm building more complex url's and I would like to have them nice and with no unneeded info. 我正在构建更复杂的url,我希望它们很好并且没有不必要的信息。

Therfore I don't want to have the typo3 controller in my url's. 因此,我不想在我的URL中使用typo3控制器。 I fixed it for normal links by using the <f:link.page> instead of the <f:link.action> link. 我通过使用<f:link.page>而不是<f:link.action>链接<f:link.action>链接。

Now I want to do the same for form's only fluid automatically ads the controller to the link. 现在,我想对表单的唯一流体执行相同操作,从而自动将控制器广告添加到链接。 I tried the following form code but it also adds the current controller: 我尝试了以下表单代码,但它也添加了当前控制器:

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

Is there a way the controller is not added? 有没有办法不添加控制器?

You can remove the controller and/or the action in the RealURL config. 您可以在RealURL配置中删除控制器和/或操作。 Below follows an example, which removes both action and controller from a detail-link. 下面是一个示例,该示例从详细信息链接中删除了动作和控制器。

$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',
        ),
);

Note, that you have to assign each page UID with your plugin (in this case page 123, which contains a detail page) to the desired configuration. 请注意,您必须将带有插件的每个页面UID (在本例中为页面123,其中包含详细信息页面)分配给所需的配置。

More information about this can be found in the extension manual of the news extension. 有关更多信息,请参见新闻扩展的扩展手册 There you will also find alternatives to the solution above for removing controller/action. 在那里,您还将找到上述解决方案的替代方案,以删除控制器/动作。

Best is to build speaking urls with the "fixedPostVars" (see other answer) and clean then long urls with the encode Hook from realurl: 最好的方法是使用“ 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