摆脱realurl中的extensionname

时间:2016-11-14 09:52:29

标签: typo3 typo3-6.2.x realurl

我尝试使用Realurl 1.12.8和TYPO3 6.2.27将生成的网址从 http://www.example.com/page/extensionname/MyArticleNumber/ 更改为 http://www.example.com/page/MyArticleNumber/ 。 我的realurl_conf.php:

'postVarSets' => array(
            '_DEFAULT' => array(
                'extensionname' => array(
                    array(
                        'GETvar' => 'extensionname_plugin[article]',
                        'lookUpTable' => array(
                            'table' => 'tx_extensionname_domain_model_article',
                            'id_field' => 'uid',
                            'alias_field' => 'CONCAT(short_title, \'-\', juq)',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'spaceCharacter' => '-',
                            ),
                        ),
                    ),
                ),
            ),

我需要编辑什么以及在哪里解决此问题? 提前谢谢。

2 个答案:

答案 0 :(得分:2)

如果您在某个特定页面使用扩展程序,则可以使用“fixedPostVars”

'fixedPostVars' => array(
    # extension configuration
    'extensionname' => array(
        array(
            'GETvar' => 'extensionname_plugin[article]',
            'lookUpTable' => array(
                'table' => 'tx_extensionname_domain_model_article',
                'id_field' => 'uid',
                'alias_field' => 'CONCAT(short_title, \'-\', juq)',
                'addWhereClause' => ' AND NOT deleted',
                'useUniqueCache' => 1,
                'useUniqueCache_conf' => array(
                    'spaceCharacter' => '-',
                ),
            ),
        ),
    ),
    # PID for extension configurations
    '99' => 'extensionname',
),

答案 1 :(得分:0)

我已经使用了realUrl的encodeSpURL_postProcdecodeSpURL_preProc函数。

以下代码已添加到我的realurl_conf.php文件中:

<?php
  $GLOBALS['realURLEncodeSpURLArray'] = array(
    'url/by/realurl/' => 'new/url/',
    'page/extensionname/' => 'page/'
  );

  function user_encodeSpURL_postProc(&$params, &$ref)
  {
    $params['URL'] = str_replace(array_keys($GLOBALS['realURLEncodeSpURLArray']), array_values($GLOBALS['realURLEncodeSpURLArray']), $params['URL']);
  }

  function user_decodeSpURL_preProc(&$params, &$ref)
  {
    $params['URL'] = str_replace(array_values($GLOBALS['realURLEncodeSpURLArray']), array_keys($GLOBALS['realURLEncodeSpURLArray']), $params['URL']);
  }

  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
    'encodeSpURL_postProc'             => array('user_encodeSpURL_postProc'),
    'decodeSpURL_preProc'              => array('user_decodeSpURL_preProc'),
    '_DEFAULT'                         => array(
       ...
  );

请确保new/url/应该是唯一的,以便不存在冲突。

例如:如果您要映射txnews,则会得到mynewspage/details/txnews/article这样的网址,您应该将mynewspage/details/txnews/替换为mynewspage/details/。请勿将txnews/替换为/