【问题标题】:Remove controller from url with typo3 and realurl使用typo3和realurl从url中删除控制器
【发布时间】:2015-05-03 13:41:09
【问题描述】:

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

因此,我不想在我的网址中使用typo3 控制器。我通过使用<f:link.page> 而不是<f:link.action> 链接为普通链接修复了它。

现在我想为表单的唯一流体自动广告控制器做同样的事情 到链接。我尝试了以下表单代码,但它也添加了当前控制器:

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

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

【问题讨论】:

    标签: typo3 fluid realurl


    【解决方案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 页,其中包含一个详细信息页面)分配给所需的配置。

    更多信息可以在新闻扩展的扩展manual 中找到。在那里,您还可以找到上述解决方案的替代方案,用于删除控制器/动作。

    【讨论】:

    • 它改进了 url,但 url 中仍然有一个额外的字段。在我的旧设置中,我的 url 例如是这样的:/auto/contoller/Ads/car.html,当我使用这个设置时,coltroller 被删除,但广告在那里,就像这样:/auto/Ads/car.html。当我使用页面链接时,控制器值也被删除,因为使用了页面默认控制器。除了我有一个多域设置,所以我不想使用页面 UID。但是将'yourDetailConfiguration' 更改为'_DEFAULT' 也可以。
    • '_DEFAULT' 事件“广告”也会添加到每个页面上。因此,使其他网址不那么干净。有没有办法让form不加控制器?
    • 很好的例子,但也可以在打字稿中添加plugin.tx_you_ext.features.skipDefaultArguments = 1。这必须从 realurl 默认 Controler 和 Action 中清除
    【解决方案2】:

    最好是用“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']);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多