繁体   English   中英

摆脱RealURL中的扩展名

[英]Get rid of extensionname in realurl

我尝试使用Realurl 1.12.8和TYPO3 6.2.27将生成的URL从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' => '-',
                            ),
                        ),
                    ),
                ),
            ),

为了解决此问题,我必须在什么地方编辑? 先感谢您。

如果您在某个特定页面上使用扩展程序,则可以使用“ 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',
),

我利用了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类的URL,则应将mynewspage/details/txnews/替换为mynewspage/details/ 不要用/替换txnews/ /

暂无
暂无

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

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